MouseTools 4.5.0__tar.gz → 5.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. {mousetools-4.5.0 → mousetools-5.0.0}/PKG-INFO +2 -1
  2. mousetools-5.0.0/mousetools/__init__.py +43 -0
  3. {mousetools-4.5.0/mousetools/mixins → mousetools-5.0.0/mousetools/_internal/http}/couchbase.py +18 -5
  4. {mousetools-4.5.0/mousetools/mixins → mousetools-5.0.0/mousetools/_internal/http}/disney.py +1 -1
  5. mousetools-5.0.0/mousetools/api/__init__.py +0 -0
  6. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools/api/menu.py +3 -3
  7. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools/api/search.py +2 -2
  8. mousetools-5.0.0/mousetools/auth.py +14 -0
  9. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools/channels/__init__.py +2 -2
  10. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools/channels/calendar/__init__.py +1 -1
  11. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools/channels/characters/__init__.py +1 -1
  12. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools/channels/facilities/__init__.py +3 -1
  13. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools/channels/facilitystatus/__init__.py +1 -1
  14. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools/channels/manager.py +23 -13
  15. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools/channels/today/__init__.py +1 -1
  16. mousetools-5.0.0/mousetools/decorators.py +13 -0
  17. mousetools-5.0.0/mousetools/mixins/__init__.py +1 -0
  18. mousetools-5.0.0/mousetools/mixins/couchbase.py +13 -0
  19. mousetools-5.0.0/mousetools/mixins/disney.py +13 -0
  20. mousetools-5.0.0/mousetools/py.typed +0 -0
  21. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools.egg-info/PKG-INFO +2 -1
  22. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools.egg-info/SOURCES.txt +11 -1
  23. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools.egg-info/requires.txt +1 -0
  24. {mousetools-4.5.0 → mousetools-5.0.0}/pyproject.toml +10 -12
  25. mousetools-5.0.0/tests/test_deprecation_shims.py +30 -0
  26. mousetools-5.0.0/tests/test_internal_layout.py +12 -0
  27. mousetools-5.0.0/tests/test_mixins.py +73 -0
  28. mousetools-5.0.0/tests/test_public_api.py +37 -0
  29. mousetools-4.5.0/mousetools/__init__.py +0 -4
  30. mousetools-4.5.0/tests/test_mixins.py +0 -37
  31. {mousetools-4.5.0 → mousetools-5.0.0}/LICENSE +0 -0
  32. {mousetools-4.5.0 → mousetools-5.0.0}/README.md +0 -0
  33. {mousetools-4.5.0/mousetools/api → mousetools-5.0.0/mousetools/_internal}/__init__.py +0 -0
  34. {mousetools-4.5.0/mousetools → mousetools-5.0.0/mousetools/_internal}/auth.py +0 -0
  35. {mousetools-4.5.0/mousetools → mousetools-5.0.0/mousetools/_internal}/decorators.py +0 -0
  36. {mousetools-4.5.0/mousetools/mixins → mousetools-5.0.0/mousetools/_internal/http}/__init__.py +0 -0
  37. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools/channels/enums.py +0 -0
  38. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools/channels/facilities/enums.py +0 -0
  39. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools/channels/forecastedwaittimes/__init__.py +0 -0
  40. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools/enums.py +0 -0
  41. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools/resources/environments.bin +0 -0
  42. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools.egg-info/dependency_links.txt +0 -0
  43. {mousetools-4.5.0 → mousetools-5.0.0}/mousetools.egg-info/top_level.txt +0 -0
  44. {mousetools-4.5.0 → mousetools-5.0.0}/setup.cfg +0 -0
  45. {mousetools-4.5.0 → mousetools-5.0.0}/tests/test_manager.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mousetools
3
- Version: 4.5.0
3
+ Version: 5.0.0
4
4
  Summary: An unofficial Python wrapper for Disney's API
5
5
  Author: Scott Caratozzolo
6
6
  License-Expression: MIT
@@ -17,6 +17,7 @@ Classifier: Operating System :: OS Independent
17
17
  Requires-Python: <4.0,>=3.9
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
+ Requires-Dist: more-itertools>=10.7.0
20
21
  Requires-Dist: pycryptodome>=3.22.0
21
22
  Requires-Dist: python-dateutil>=2.9.0.post0
22
23
  Requires-Dist: requests>=2.32.3
@@ -0,0 +1,43 @@
1
+ import logging
2
+
3
+ from mousetools.api.menu import Menu, MenuGroup, MenuItem, Menus
4
+ from mousetools.api.search import Search
5
+ from mousetools.channels import CouchbaseChannel, CouchbaseChildChannel
6
+ from mousetools.channels.calendar import CalendarChannel, CalendarChildChannel
7
+ from mousetools.channels.characters import CharactersChannel, CharactersChildChannel
8
+ from mousetools.channels.facilities import FacilityChannel
9
+ from mousetools.channels.facilitystatus import FacilityStatusChannel, FacilityStatusChildChannel
10
+ from mousetools.channels.forecastedwaittimes import (
11
+ ForecastedWaitTimesChannel,
12
+ ForecastedWaitTimesChildChannel,
13
+ )
14
+ from mousetools.channels.manager import ChannelManager
15
+ from mousetools.channels.today import TodayChannel, TodayChildChannel
16
+ from mousetools.enums import DestinationShort, EntityType
17
+
18
+ logger = logging.getLogger(__name__)
19
+ logger.addHandler(logging.NullHandler())
20
+
21
+ __all__ = [
22
+ "CalendarChannel",
23
+ "CalendarChildChannel",
24
+ "ChannelManager",
25
+ "CharactersChannel",
26
+ "CharactersChildChannel",
27
+ "CouchbaseChannel",
28
+ "CouchbaseChildChannel",
29
+ "DestinationShort",
30
+ "EntityType",
31
+ "FacilityChannel",
32
+ "FacilityStatusChannel",
33
+ "FacilityStatusChildChannel",
34
+ "ForecastedWaitTimesChannel",
35
+ "ForecastedWaitTimesChildChannel",
36
+ "Menu",
37
+ "MenuGroup",
38
+ "MenuItem",
39
+ "Menus",
40
+ "Search",
41
+ "TodayChannel",
42
+ "TodayChildChannel",
43
+ ]
@@ -5,7 +5,7 @@ from typing import Union
5
5
 
6
6
  import requests
7
7
 
8
- from mousetools.auth import auth_obj
8
+ from mousetools._internal.auth import auth_obj
9
9
 
10
10
  logger = logging.getLogger(__name__)
11
11
 
@@ -37,9 +37,15 @@ class CouchbaseMixin:
37
37
  "json": True,
38
38
  }
39
39
 
40
- logger.info("Sending request for channel data: %s", _channel_names)
40
+ logger.info(
41
+ "Sending request for channel data: %s", f"{len(channel_name)} channels" if return_list else _channel_names
42
+ )
41
43
  response = requests.post(self._couchbase_url + "/_bulk_get", json=payload, headers=self._headers, timeout=10)
42
- logger.debug("Response status for %s: %s", _channel_names, response.status_code)
44
+ logger.debug(
45
+ "Response status for %s: %s",
46
+ f"{len(channel_name)} channels" if return_list else _channel_names,
47
+ response.status_code,
48
+ )
43
49
  results = []
44
50
  try:
45
51
  response.raise_for_status()
@@ -93,9 +99,16 @@ class CouchbaseMixin:
93
99
  if since:
94
100
  payload["since"] = since
95
101
 
96
- logger.info("Sending request for channel changes: %s", channel_name)
102
+ logger.info(
103
+ "Sending request for channel changes: %s",
104
+ f"{len(channel_name)} channels" if len(channel_name) > 1 else channel_name[0],
105
+ )
97
106
  response = requests.post(self._couchbase_url + "/_changes", json=payload, headers=self._headers, timeout=10)
98
- logger.debug("Response status for %s: %s", channel_name, response.status_code)
107
+ logger.debug(
108
+ "Response status for %s: %s",
109
+ f"{len(channel_name)} channels" if len(channel_name) > 1 else channel_name[0],
110
+ response.status_code,
111
+ )
99
112
  response.raise_for_status()
100
113
  data = response.json()
101
114
  except requests.HTTPError as err:
@@ -4,7 +4,7 @@ from typing import Union
4
4
 
5
5
  import requests
6
6
 
7
- from mousetools.auth import auth_obj
7
+ from mousetools._internal.auth import auth_obj
8
8
 
9
9
  logger = logging.getLogger(__name__)
10
10
 
File without changes
@@ -5,9 +5,9 @@ from zoneinfo import ZoneInfo
5
5
 
6
6
  from dateutil.parser import isoparse
7
7
 
8
- from mousetools.auth import auth_obj
9
- from mousetools.decorators import disney_property, json_property
10
- from mousetools.mixins.disney import DisneyAPIMixin
8
+ from mousetools._internal.auth import auth_obj
9
+ from mousetools._internal.decorators import disney_property, json_property
10
+ from mousetools._internal.http.disney import DisneyAPIMixin
11
11
 
12
12
  logger = logging.getLogger(__name__)
13
13
 
@@ -1,9 +1,9 @@
1
1
  from typing import Optional, Union
2
2
 
3
- from mousetools.auth import auth_obj
3
+ from mousetools._internal.auth import auth_obj
4
+ from mousetools._internal.http.disney import DisneyAPIMixin
4
5
  from mousetools.channels.enums import DLRCouchbaseChannels, WDWCouchbaseChannels
5
6
  from mousetools.enums import DestinationShort
6
- from mousetools.mixins.disney import DisneyAPIMixin
7
7
 
8
8
 
9
9
  class Search(DisneyAPIMixin):
@@ -0,0 +1,14 @@
1
+ """Deprecated. Import from ``mousetools._internal.auth`` instead. Removed in 6.0."""
2
+
3
+ import warnings
4
+
5
+ from mousetools._internal.auth import Authentication, auth_obj
6
+
7
+ warnings.warn(
8
+ "mousetools.auth is deprecated; import from mousetools._internal.auth "
9
+ "(internal) or use the top-level mousetools public API. Removed in 6.0.",
10
+ DeprecationWarning,
11
+ stacklevel=2,
12
+ )
13
+
14
+ __all__ = ["Authentication", "auth_obj"]
@@ -5,10 +5,10 @@ from typing import Any, Optional, Union
5
5
 
6
6
  from dateutil.parser import isoparse
7
7
 
8
+ from mousetools._internal.decorators import disney_property
9
+ from mousetools._internal.http.couchbase import CouchbaseMixin
8
10
  from mousetools.channels.enums import DestinationTimezones, DLRCouchbaseChannels, WDWCouchbaseChannels
9
- from mousetools.decorators import disney_property
10
11
  from mousetools.enums import DestinationShort, EntityType
11
- from mousetools.mixins.couchbase import CouchbaseMixin
12
12
 
13
13
  logger = logging.getLogger(__name__)
14
14
 
@@ -5,9 +5,9 @@ from zoneinfo import ZoneInfo
5
5
 
6
6
  from dateutil.parser import isoparse
7
7
 
8
+ from mousetools._internal.decorators import disney_property
8
9
  from mousetools.channels import CouchbaseChannel, CouchbaseChildChannel
9
10
  from mousetools.channels.enums import CouchbaseChannels
10
- from mousetools.decorators import disney_property
11
11
 
12
12
  logger = logging.getLogger(__name__)
13
13
 
@@ -3,9 +3,9 @@ from typing import Optional
3
3
 
4
4
  from dateutil.parser import isoparse
5
5
 
6
+ from mousetools._internal.decorators import disney_property
6
7
  from mousetools.channels import CouchbaseChannel, CouchbaseChildChannel
7
8
  from mousetools.channels.enums import CouchbaseChannels
8
- from mousetools.decorators import disney_property
9
9
 
10
10
  logger = logging.getLogger(__name__)
11
11
 
@@ -6,6 +6,9 @@ from zoneinfo import ZoneInfo
6
6
 
7
7
  import requests
8
8
 
9
+ from mousetools._internal.decorators import disney_property
10
+
11
+ # tach-ignore(issue 34 - FacilityChildChannel.get_menu coupling to api.menu is pre-existing debt, to be removed by the issue 34 god-class refactor)
9
12
  from mousetools.api.menu import Menus
10
13
  from mousetools.channels import CouchbaseChannel, CouchbaseChildChannel
11
14
  from mousetools.channels.calendar import CalendarChildChannel
@@ -17,7 +20,6 @@ from mousetools.channels.enums import (
17
20
  from mousetools.channels.facilitystatus import FacilityStatusChildChannel
18
21
  from mousetools.channels.forecastedwaittimes import ForecastedWaitTimesChildChannel
19
22
  from mousetools.channels.today import TodayChildChannel
20
- from mousetools.decorators import disney_property
21
23
  from mousetools.enums import DestinationShort, EntityType
22
24
 
23
25
  logger = logging.getLogger(__name__)
@@ -4,9 +4,9 @@ from typing import Any, Optional
4
4
 
5
5
  from dateutil.parser import isoparse
6
6
 
7
+ from mousetools._internal.decorators import disney_property
7
8
  from mousetools.channels import CouchbaseChannel, CouchbaseChildChannel
8
9
  from mousetools.channels.enums import CouchbaseChannels
9
- from mousetools.decorators import disney_property
10
10
  from mousetools.enums import EntityType
11
11
 
12
12
  logger = logging.getLogger(__name__)
@@ -1,8 +1,10 @@
1
1
  import logging
2
2
  from typing import Optional, Union
3
3
 
4
+ from more_itertools import batched
5
+
6
+ from mousetools._internal.http.couchbase import CouchbaseMixin
4
7
  from mousetools.channels import CouchbaseChannel, CouchbaseChildChannel
5
- from mousetools.mixins.couchbase import CouchbaseMixin
6
8
 
7
9
  logger = logging.getLogger(__name__)
8
10
 
@@ -84,20 +86,28 @@ class ChannelManager(CouchbaseMixin):
84
86
  "Refreshing %d children channels and %d parent channels", len(children_channels), len(parent_channels)
85
87
  )
86
88
 
89
+ self._refresh_children(children_channels)
90
+
91
+ self._refresh_parents(parent_channels)
92
+
93
+ def _refresh_children(self, children_channels: dict[str, CouchbaseChildChannel]) -> None:
87
94
  if children_channels:
88
95
  logger.debug("Refreshing children channels")
89
- children_results = self.get_channel_data(list(children_channels.keys()))
90
- for children_channel, result in zip(children_channels.values(), children_results):
91
- children_channel._refresh_from_manager(result)
96
+ for _channels in batched(children_channels, 100):
97
+ children_results = self.get_channel_data(_channels)
98
+ for channel_id, result in zip(_channels, children_results):
99
+ children_channels[channel_id]._refresh_from_manager(result)
92
100
 
101
+ def _refresh_parents(self, parent_channels: dict[str, CouchbaseChannel]) -> None:
93
102
  if parent_channels:
94
103
  logger.debug("Refreshing parent channels")
95
- parent_results = self.get_channel_changes(list(parent_channels.keys()))
96
- for channel_id, parent_channel in parent_channels.items():
97
- copy_results = parent_results.copy()
98
- new_results = []
99
- for result in copy_results["results"]:
100
- if channel_id in result["id"]:
101
- new_results.append(result)
102
- copy_results["results"] = new_results
103
- parent_channel._refresh_from_manager(copy_results)
104
+ for _channels in batched(parent_channels, 100):
105
+ parent_results = self.get_channel_changes(_channels)
106
+ for channel_id in _channels:
107
+ copy_results = parent_results.copy()
108
+ new_results = []
109
+ for result in copy_results["results"]:
110
+ if channel_id in result["id"]:
111
+ new_results.append(result)
112
+ copy_results["results"] = new_results
113
+ parent_channels[channel_id]._refresh_from_manager(copy_results)
@@ -4,8 +4,8 @@ from typing import Optional
4
4
 
5
5
  from dateutil.parser import isoparse
6
6
 
7
+ from mousetools._internal.decorators import disney_property
7
8
  from mousetools.channels import CouchbaseChannel, CouchbaseChildChannel
8
- from mousetools.decorators import disney_property
9
9
  from mousetools.enums import EntityType
10
10
 
11
11
  logger = logging.getLogger(__name__)
@@ -0,0 +1,13 @@
1
+ """Deprecated. Import from ``mousetools._internal.decorators`` instead. Removed in 6.0."""
2
+
3
+ import warnings
4
+
5
+ from mousetools._internal.decorators import disney_property, json_property
6
+
7
+ warnings.warn(
8
+ "mousetools.decorators is deprecated; import from mousetools._internal.decorators. Removed in 6.0.",
9
+ DeprecationWarning,
10
+ stacklevel=2,
11
+ )
12
+
13
+ __all__ = ["disney_property", "json_property"]
@@ -0,0 +1 @@
1
+ """Deprecated. Import from ``mousetools._internal.http`` instead. Removed in 6.0."""
@@ -0,0 +1,13 @@
1
+ """Deprecated. Import from ``mousetools._internal.http.couchbase`` instead. Removed in 6.0."""
2
+
3
+ import warnings
4
+
5
+ from mousetools._internal.http.couchbase import CouchbaseMixin
6
+
7
+ warnings.warn(
8
+ "mousetools.mixins.couchbase is deprecated; import from mousetools._internal.http.couchbase. Removed in 6.0.",
9
+ DeprecationWarning,
10
+ stacklevel=2,
11
+ )
12
+
13
+ __all__ = ["CouchbaseMixin"]
@@ -0,0 +1,13 @@
1
+ """Deprecated. Import from ``mousetools._internal.http.disney`` instead. Removed in 6.0."""
2
+
3
+ import warnings
4
+
5
+ from mousetools._internal.http.disney import DisneyAPIMixin
6
+
7
+ warnings.warn(
8
+ "mousetools.mixins.disney is deprecated; import from mousetools._internal.http.disney. Removed in 6.0.",
9
+ DeprecationWarning,
10
+ stacklevel=2,
11
+ )
12
+
13
+ __all__ = ["DisneyAPIMixin"]
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mousetools
3
- Version: 4.5.0
3
+ Version: 5.0.0
4
4
  Summary: An unofficial Python wrapper for Disney's API
5
5
  Author: Scott Caratozzolo
6
6
  License-Expression: MIT
@@ -17,6 +17,7 @@ Classifier: Operating System :: OS Independent
17
17
  Requires-Python: <4.0,>=3.9
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
+ Requires-Dist: more-itertools>=10.7.0
20
21
  Requires-Dist: pycryptodome>=3.22.0
21
22
  Requires-Dist: python-dateutil>=2.9.0.post0
22
23
  Requires-Dist: requests>=2.32.3
@@ -5,11 +5,18 @@ mousetools/__init__.py
5
5
  mousetools/auth.py
6
6
  mousetools/decorators.py
7
7
  mousetools/enums.py
8
+ mousetools/py.typed
8
9
  mousetools.egg-info/PKG-INFO
9
10
  mousetools.egg-info/SOURCES.txt
10
11
  mousetools.egg-info/dependency_links.txt
11
12
  mousetools.egg-info/requires.txt
12
13
  mousetools.egg-info/top_level.txt
14
+ mousetools/_internal/__init__.py
15
+ mousetools/_internal/auth.py
16
+ mousetools/_internal/decorators.py
17
+ mousetools/_internal/http/__init__.py
18
+ mousetools/_internal/http/couchbase.py
19
+ mousetools/_internal/http/disney.py
13
20
  mousetools/api/__init__.py
14
21
  mousetools/api/menu.py
15
22
  mousetools/api/search.py
@@ -27,5 +34,8 @@ mousetools/mixins/__init__.py
27
34
  mousetools/mixins/couchbase.py
28
35
  mousetools/mixins/disney.py
29
36
  mousetools/resources/environments.bin
37
+ tests/test_deprecation_shims.py
38
+ tests/test_internal_layout.py
30
39
  tests/test_manager.py
31
- tests/test_mixins.py
40
+ tests/test_mixins.py
41
+ tests/test_public_api.py
@@ -1,3 +1,4 @@
1
+ more-itertools>=10.7.0
1
2
  pycryptodome>=3.22.0
2
3
  python-dateutil>=2.9.0.post0
3
4
  requests>=2.32.3
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mousetools"
3
- version = "4.5.0"
3
+ version = "5.0.0"
4
4
  authors = [{name = "Scott Caratozzolo"}]
5
5
  description = "An unofficial Python wrapper for Disney's API"
6
6
  readme = "README.md"
@@ -8,6 +8,7 @@ license = "MIT"
8
8
  license-files = ["LICENSE"]
9
9
  requires-python = ">=3.9, <4.0"
10
10
  dependencies = [
11
+ "more-itertools>=10.7.0",
11
12
  "pycryptodome>=3.22.0",
12
13
  "python-dateutil>=2.9.0.post0",
13
14
  "requests>=2.32.3",
@@ -33,7 +34,6 @@ dev-dependencies = [
33
34
  "mkdocs>=1.6.1",
34
35
  "mkdocs-material>=9.5.33",
35
36
  "mkdocstrings[python]>=0.25.2",
36
- "mypy>=1.11.2",
37
37
  "pre-commit>=3.5.0",
38
38
  "pytest-cov>=5.0.0",
39
39
  "pytest>=8.3.2",
@@ -43,6 +43,8 @@ dev-dependencies = [
43
43
  "icecream>=2.1.4",
44
44
  "pytest-mock>=3.14.0",
45
45
  "responses>=0.25.7",
46
+ "tach>=0.29.0",
47
+ "pyrefly>=0.16.0",
46
48
  ]
47
49
 
48
50
  [build-system]
@@ -51,7 +53,7 @@ build-backend = "setuptools.build_meta"
51
53
  include-package-data = true
52
54
 
53
55
  [tool.setuptools.package-data]
54
- "mousetools" = ["resources/*"]
56
+ "mousetools" = ["resources/*", "py.typed"]
55
57
 
56
58
  [tool.commitizen]
57
59
  tag_format = "v$version"
@@ -137,12 +139,8 @@ ignore = [
137
139
  ]
138
140
 
139
141
 
140
- [tool.mypy]
141
- python_version = "3.9"
142
- files = ["mousetools"]
143
- disallow_untyped_defs = "True"
144
- disallow_any_unimported = "True"
145
- no_implicit_optional = "True"
146
- check_untyped_defs = "True"
147
- warn_unused_ignores = "True"
148
- show_error_codes = "True"
142
+ [tool.pyrefly]
143
+ project-includes = ["mousetools"]
144
+ project-excludes = ["mousetools/auth.py", "mousetools/decorators.py", "mousetools/mixins"]
145
+ python-version = "3.9"
146
+ baseline = "pyrefly-baseline.json"
@@ -0,0 +1,30 @@
1
+ import pytest
2
+
3
+
4
+ def test_auth_shim_warns_and_reexports():
5
+ with pytest.warns(DeprecationWarning, match="mousetools._internal.auth"):
6
+ from mousetools.auth import auth_obj
7
+
8
+ from mousetools._internal.auth import auth_obj as auth_obj_real
9
+
10
+ assert auth_obj is auth_obj_real
11
+
12
+
13
+ def test_decorators_shim_warns_and_reexports():
14
+ with pytest.warns(DeprecationWarning, match="mousetools._internal.decorators"):
15
+ from mousetools.decorators import disney_property
16
+
17
+ from mousetools._internal.decorators import disney_property as disney_property_real
18
+
19
+ assert disney_property is disney_property_real
20
+
21
+
22
+ def test_mixins_shim_warns_and_reexports():
23
+ with pytest.warns(DeprecationWarning, match="mousetools._internal.http"):
24
+ from mousetools.mixins.couchbase import CouchbaseMixin
25
+
26
+ from mousetools._internal.http.couchbase import (
27
+ CouchbaseMixin as couchbase_mixin_real, # noqa: N813
28
+ )
29
+
30
+ assert CouchbaseMixin is couchbase_mixin_real
@@ -0,0 +1,12 @@
1
+ def test_internal_modules_importable_from_new_paths():
2
+ from mousetools._internal.auth import Authentication, auth_obj
3
+ from mousetools._internal.decorators import disney_property, json_property
4
+ from mousetools._internal.http.couchbase import CouchbaseMixin
5
+ from mousetools._internal.http.disney import DisneyAPIMixin
6
+
7
+ assert auth_obj is not None
8
+ assert callable(disney_property)
9
+ assert callable(json_property)
10
+ assert Authentication is not None
11
+ assert CouchbaseMixin is not None
12
+ assert DisneyAPIMixin is not None
@@ -0,0 +1,73 @@
1
+ import json
2
+
3
+ import responses
4
+
5
+ from mousetools._internal.auth import auth_obj
6
+ from mousetools._internal.http.couchbase import CouchbaseMixin
7
+ from mousetools._internal.http.disney import DisneyAPIMixin
8
+
9
+ _ATTRACTION_ID = "wdw.facilities.1_0.en_us.attraction.80010177;entityType=Attraction"
10
+ _BULK_GET = CouchbaseMixin._couchbase_url + "/_bulk_get"
11
+ _CHANGES = CouchbaseMixin._couchbase_url + "/_changes"
12
+
13
+
14
+ @responses.activate
15
+ def test_couchbase_mixin():
16
+ cb = CouchbaseMixin()
17
+
18
+ # _bulk_get returns a multipart-ish text body parsed line-by-line as JSON.
19
+ # First real-URL call -> a valid document; second -> a not_found error doc (FIFO order).
20
+ responses.add(
21
+ responses.POST,
22
+ _BULK_GET,
23
+ body=json.dumps({"id": _ATTRACTION_ID, "name": "Pirates of the Caribbean"}),
24
+ status=200,
25
+ )
26
+ responses.add(
27
+ responses.POST,
28
+ _BULK_GET,
29
+ body=json.dumps({"id": "wdw.notreal.1_0", "error": "not_found"}),
30
+ status=200,
31
+ )
32
+ # _changes returns JSON.
33
+ responses.add(
34
+ responses.POST,
35
+ _CHANGES,
36
+ json={"results": [{"seq": 1, "id": _ATTRACTION_ID, "changes": []}], "last_seq": "1"},
37
+ status=200,
38
+ )
39
+ # An unreachable host returns an HTTP error, which the mixin maps to None.
40
+ responses.add(responses.POST, "http://notreal.com/_bulk_get", status=404)
41
+ responses.add(responses.POST, "http://notreal.com/_changes", status=404)
42
+
43
+ channel_data = cb.get_channel_data(_ATTRACTION_ID)
44
+ channel_changes = cb.get_channel_changes("wdw.facilities.1_0.en_us")
45
+
46
+ assert channel_data
47
+ assert channel_data["id"] == _ATTRACTION_ID
48
+
49
+ assert channel_changes
50
+ assert len(channel_changes["results"]) > 0
51
+
52
+ channel_data = cb.get_channel_data("wdw.notreal.1_0")
53
+ assert channel_data.get("error", "") == "not_found"
54
+
55
+ cb._couchbase_url = "http://notreal.com"
56
+ channel_data = cb.get_channel_data(_ATTRACTION_ID)
57
+ channel_changes = cb.get_channel_changes("wdw.facilities.1_0.en_us", since=3900000)
58
+ assert channel_data is None
59
+ assert channel_changes is None
60
+
61
+
62
+ def test_disney_mixin():
63
+ disney = DisneyAPIMixin()
64
+ data = disney.get_disney_data(
65
+ f"{auth_obj._environments['serviceMenuUrl']}/diningMenuSvc/orchestration/menus/17936197"
66
+ )
67
+
68
+ assert data
69
+ assert "menus" in data
70
+
71
+ data = disney.get_disney_data("http://notreal.com")
72
+
73
+ assert data is None
@@ -0,0 +1,37 @@
1
+ import importlib
2
+
3
+ import mousetools
4
+
5
+ EXPECTED = {
6
+ "CouchbaseChannel",
7
+ "CouchbaseChildChannel",
8
+ "ChannelManager",
9
+ "FacilityChannel",
10
+ "FacilityStatusChannel",
11
+ "FacilityStatusChildChannel",
12
+ "CalendarChannel",
13
+ "CalendarChildChannel",
14
+ "CharactersChannel",
15
+ "CharactersChildChannel",
16
+ "TodayChannel",
17
+ "TodayChildChannel",
18
+ "ForecastedWaitTimesChannel",
19
+ "ForecastedWaitTimesChildChannel",
20
+ "Search",
21
+ "Menus",
22
+ "Menu",
23
+ "MenuGroup",
24
+ "MenuItem",
25
+ "DestinationShort",
26
+ "EntityType",
27
+ }
28
+
29
+
30
+ def test_all_matches_expected():
31
+ assert set(mousetools.__all__) == EXPECTED
32
+
33
+
34
+ def test_every_public_name_is_importable():
35
+ mod = importlib.import_module("mousetools")
36
+ for name in mod.__all__:
37
+ assert hasattr(mod, name), f"{name} missing from top-level mousetools"
@@ -1,4 +0,0 @@
1
- import logging
2
-
3
- logger = logging.getLogger(__name__)
4
- logger.addHandler(logging.NullHandler())
@@ -1,37 +0,0 @@
1
- from mousetools.auth import auth_obj
2
- from mousetools.mixins.couchbase import CouchbaseMixin
3
- from mousetools.mixins.disney import DisneyAPIMixin
4
-
5
-
6
- def test_couchbase_mixin():
7
- cb = CouchbaseMixin()
8
- channel_data = cb.get_channel_data("wdw.facilities.1_0.en_us.attraction.80010177;entityType=Attraction")
9
- channel_changes = cb.get_channel_changes("wdw.facilities.1_0.en_us")
10
-
11
- assert channel_data
12
-
13
- assert channel_changes
14
- assert len(channel_changes["results"]) > 0
15
-
16
- channel_data = cb.get_channel_data("wdw.notreal.1_0")
17
- assert channel_data.get("error", "") == "not_found"
18
-
19
- cb._couchbase_url = "http://notreal.com"
20
- channel_data = cb.get_channel_data("wdw.facilities.1_0.en_us.attraction.80010177;entityType=Attraction")
21
- channel_changes = cb.get_channel_changes("wdw.facilities.1_0.en_us", since=3900000)
22
- assert channel_data is None
23
- assert channel_changes is None
24
-
25
-
26
- def test_disney_mixin():
27
- disney = DisneyAPIMixin()
28
- data = disney.get_disney_data(
29
- f"{auth_obj._environments['serviceMenuUrl']}/diningMenuSvc/orchestration/menus/17936197"
30
- )
31
-
32
- assert data
33
- assert "menus" in data
34
-
35
- data = disney.get_disney_data("http://notreal.com")
36
-
37
- assert data is None
File without changes
File without changes
File without changes