aa-fleetfinder 2.7.1__py3-none-any.whl → 3.0.0b1__py3-none-any.whl

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.

Potentially problematic release.


This version of aa-fleetfinder might be problematic. Click here for more details.

Files changed (35) hide show
  1. {aa_fleetfinder-2.7.1.dist-info → aa_fleetfinder-3.0.0b1.dist-info}/METADATA +5 -14
  2. {aa_fleetfinder-2.7.1.dist-info → aa_fleetfinder-3.0.0b1.dist-info}/RECORD +35 -35
  3. fleetfinder/__init__.py +5 -3
  4. fleetfinder/apps.py +5 -4
  5. fleetfinder/locale/cs_CZ/LC_MESSAGES/django.po +21 -22
  6. fleetfinder/locale/de/LC_MESSAGES/django.mo +0 -0
  7. fleetfinder/locale/de/LC_MESSAGES/django.po +27 -24
  8. fleetfinder/locale/django.pot +22 -23
  9. fleetfinder/locale/es/LC_MESSAGES/django.po +25 -22
  10. fleetfinder/locale/fr_FR/LC_MESSAGES/django.mo +0 -0
  11. fleetfinder/locale/fr_FR/LC_MESSAGES/django.po +67 -59
  12. fleetfinder/locale/it_IT/LC_MESSAGES/django.po +21 -22
  13. fleetfinder/locale/ja/LC_MESSAGES/django.po +25 -22
  14. fleetfinder/locale/ko_KR/LC_MESSAGES/django.po +25 -22
  15. fleetfinder/locale/nl_NL/LC_MESSAGES/django.po +21 -22
  16. fleetfinder/locale/pl_PL/LC_MESSAGES/django.po +21 -22
  17. fleetfinder/locale/ru/LC_MESSAGES/django.po +25 -22
  18. fleetfinder/locale/sk/LC_MESSAGES/django.po +21 -22
  19. fleetfinder/locale/uk/LC_MESSAGES/django.mo +0 -0
  20. fleetfinder/locale/uk/LC_MESSAGES/django.po +50 -56
  21. fleetfinder/locale/zh_Hans/LC_MESSAGES/django.mo +0 -0
  22. fleetfinder/locale/zh_Hans/LC_MESSAGES/django.po +28 -25
  23. fleetfinder/providers.py +22 -4
  24. fleetfinder/tasks.py +279 -110
  25. fleetfinder/tests/__init__.py +39 -1
  26. fleetfinder/tests/test_access.py +2 -2
  27. fleetfinder/tests/test_auth_hooks.py +2 -2
  28. fleetfinder/tests/test_settings.py +3 -2
  29. fleetfinder/tests/test_tasks.py +1010 -34
  30. fleetfinder/tests/test_templatetags.py +2 -4
  31. fleetfinder/tests/test_user_agent.py +62 -14
  32. fleetfinder/tests/test_views.py +700 -52
  33. fleetfinder/views.py +102 -55
  34. {aa_fleetfinder-2.7.1.dist-info → aa_fleetfinder-3.0.0b1.dist-info}/WHEEL +0 -0
  35. {aa_fleetfinder-2.7.1.dist-info → aa_fleetfinder-3.0.0b1.dist-info}/licenses/LICENSE +0 -0
@@ -2,14 +2,12 @@
2
2
  Test the apps' template tags
3
3
  """
4
4
 
5
- # Django
6
- from django.test import TestCase
7
-
8
5
  # AA Fleet Finder
9
6
  from fleetfinder.templatetags.fleetfinder import get_item
7
+ from fleetfinder.tests import BaseTestCase
10
8
 
11
9
 
12
- class TestGetItem(TestCase):
10
+ class TestGetItem(BaseTestCase):
13
11
  """
14
12
  Test the `get_item` template tag
15
13
  """
@@ -2,39 +2,87 @@
2
2
  Test user agent header for ESI requests
3
3
  """
4
4
 
5
+ # Standard Library
6
+ from unittest.mock import MagicMock, patch
7
+
8
+ # Third Party
9
+ import httpx
10
+
5
11
  # Django
6
12
  from django.conf import settings
7
- from django.test import TestCase
8
13
 
9
14
  # Alliance Auth
10
15
  from esi import __url__ as esi_url
11
16
  from esi import __version__ as esi_version
17
+ from esi.openapi_clients import ESIClientProvider
18
+ from esi.tests.test_openapi import SPEC_PATH
12
19
 
13
20
  # AA Fleet Finder
14
- from fleetfinder import __app_name_useragent__, __github_url__, __version__
15
- from fleetfinder.providers import esi
21
+ from fleetfinder import (
22
+ __app_name_verbose__,
23
+ __esi_compatibility_date__,
24
+ __github_url__,
25
+ __version__,
26
+ )
27
+ from fleetfinder.tests import BaseTestCase
16
28
 
17
29
 
18
- class TestUserAgent(TestCase):
30
+ class TestUserAgent(BaseTestCase):
19
31
  """
20
- Test the user agent header for ESI requests
32
+ Test suite for verifying the `User-Agent` header in ESI requests.
21
33
  """
22
34
 
23
- def test_user_agent_header(self):
35
+ @patch.object(httpx.Client, "send")
36
+ def test_user_agent_header(self, send: MagicMock):
24
37
  """
25
- Test that the user agent header is set correctly for ESI requests.
38
+ Test that the `User-Agent` header is correctly set in ESI requests.
39
+
40
+ This test verifies that the `User-Agent` header in HTTP requests made by the ESI client
41
+ is constructed correctly based on the provided application name, version, and other metadata.
26
42
 
27
- :return:
28
- :rtype:
43
+ Args:
44
+ send (MagicMock): A mocked `httpx.Client.send` method to intercept HTTP requests and provide a controlled response.
45
+
46
+ Assertions:
47
+ - The `User-Agent` header in the HTTP request matches the expected format.
48
+ - The `players` field in the response JSON is correctly parsed and matches the expected value.
29
49
  """
30
50
 
31
- operation = esi.client.Universe.get_universe_factions()
51
+ # Initialize the ESI client provider with test-specific metadata
52
+ esi = ESIClientProvider(
53
+ ua_appname=__app_name_verbose__, # Application name for the User-Agent header
54
+ ua_url=__github_url__, # Application URL for the User-Agent header
55
+ ua_version=__version__, # Application version for the User-Agent header
56
+ compatibility_date=__esi_compatibility_date__, # Compatibility date for the ESI spec
57
+ spec_file=SPEC_PATH, # Path to the OpenAPI specification file
58
+ )
59
+
60
+ # Mock the HTTP response returned by the `send` method
61
+ send.return_value = httpx.Response(
62
+ status_code=200, # HTTP status code for the response
63
+ json={ # Mocked JSON response body
64
+ "players": 1234,
65
+ "server_version": "1234",
66
+ "start_time": "2029-09-19T11:02:08Z",
67
+ },
68
+ request=httpx.Request(method="GET", url="test"), # Mocked HTTP request
69
+ )
70
+
71
+ # Perform the ESI client request and retrieve the status
72
+ status = esi.client.Status.GetStatus().result()
32
73
 
74
+ # Retrieve the arguments passed to the mocked `send` method
75
+ call_args, call_kwargs = send.call_args
76
+
77
+ # Assert that the `User-Agent` header matches the expected format
33
78
  self.assertEqual(
34
- operation.future.request.headers["User-Agent"],
35
- (
36
- f"{__app_name_useragent__}/{__version__} "
79
+ first=call_args[0].headers["user-agent"],
80
+ second=(
81
+ f"AaFleetFinder/{__version__} "
37
82
  f"({settings.ESI_USER_CONTACT_EMAIL}; +{__github_url__}) "
38
- f"Django-ESI/{esi_version} (+{esi_url})"
83
+ f"DjangoEsi/{esi_version} (+{esi_url})"
39
84
  ),
40
85
  )
86
+
87
+ # Assert that the `players` field in the response matches the expected value
88
+ self.assertEqual(first=status.players, second=1234)