aa-intel-tool 2.6.1__py3-none-any.whl → 2.6.3__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.
Files changed (67) hide show
  1. aa_intel_tool/__init__.py +1 -1
  2. aa_intel_tool/helper/eve_character.py +24 -36
  3. aa_intel_tool/helper/static_files.py +2 -2
  4. aa_intel_tool/locale/cs_CZ/LC_MESSAGES/django.po +30 -29
  5. aa_intel_tool/locale/de/LC_MESSAGES/django.mo +0 -0
  6. aa_intel_tool/locale/de/LC_MESSAGES/django.po +36 -35
  7. aa_intel_tool/locale/django.pot +31 -30
  8. aa_intel_tool/locale/es/LC_MESSAGES/django.po +32 -29
  9. aa_intel_tool/locale/fr_FR/LC_MESSAGES/django.mo +0 -0
  10. aa_intel_tool/locale/fr_FR/LC_MESSAGES/django.po +38 -33
  11. aa_intel_tool/locale/it_IT/LC_MESSAGES/django.po +30 -29
  12. aa_intel_tool/locale/ja/LC_MESSAGES/django.po +30 -29
  13. aa_intel_tool/locale/ko_KR/LC_MESSAGES/django.mo +0 -0
  14. aa_intel_tool/locale/ko_KR/LC_MESSAGES/django.po +39 -33
  15. aa_intel_tool/locale/nl_NL/LC_MESSAGES/django.po +30 -29
  16. aa_intel_tool/locale/pl_PL/LC_MESSAGES/django.po +30 -29
  17. aa_intel_tool/locale/ru/LC_MESSAGES/django.mo +0 -0
  18. aa_intel_tool/locale/ru/LC_MESSAGES/django.po +38 -33
  19. aa_intel_tool/locale/sk/LC_MESSAGES/django.po +30 -29
  20. aa_intel_tool/locale/uk/LC_MESSAGES/django.mo +0 -0
  21. aa_intel_tool/locale/uk/LC_MESSAGES/django.po +129 -123
  22. aa_intel_tool/locale/zh_Hans/LC_MESSAGES/django.po +32 -29
  23. aa_intel_tool/parser/general.py +11 -16
  24. aa_intel_tool/parser/helper/db.py +8 -11
  25. aa_intel_tool/parser/module/chatlist.py +97 -126
  26. aa_intel_tool/parser/module/dscan.py +115 -147
  27. aa_intel_tool/parser/module/fleetcomp.py +85 -102
  28. aa_intel_tool/static/aa_intel_tool/css/aa-intel-tool.css +6 -19
  29. aa_intel_tool/static/aa_intel_tool/css/aa-intel-tool.min.css +1 -1
  30. aa_intel_tool/static/aa_intel_tool/css/aa-intel-tool.min.css.map +1 -1
  31. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan-highlight.js +104 -64
  32. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan-highlight.min.js +1 -1
  33. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan-highlight.min.js.map +1 -1
  34. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan.js +59 -59
  35. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan.min.js +1 -1
  36. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan.min.js.map +1 -1
  37. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan-highlight.js +43 -43
  38. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan-highlight.min.js +1 -1
  39. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan-highlight.min.js.map +1 -1
  40. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan.js +146 -105
  41. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan.min.js +1 -1
  42. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan.min.js.map +1 -1
  43. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition-highlight.js +51 -51
  44. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition-highlight.min.js +1 -1
  45. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition-highlight.min.js.map +1 -1
  46. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition.js +69 -59
  47. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition.min.js +1 -1
  48. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition.min.js.map +1 -1
  49. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-scan-result-common.js +54 -32
  50. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-scan-result-common.min.js +1 -1
  51. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-scan-result-common.min.js.map +1 -1
  52. aa_intel_tool/templates/aa_intel_tool/base.html +4 -2
  53. aa_intel_tool/templates/aa_intel_tool/partials/scan/chatlist/alliances.html +0 -2
  54. aa_intel_tool/templates/aa_intel_tool/partials/scan/chatlist/corporations.html +0 -2
  55. aa_intel_tool/templates/aa_intel_tool/partials/scan/chatlist/pilots.html +0 -2
  56. aa_intel_tool/templates/aa_intel_tool/partials/scan/evetime.html +1 -1
  57. aa_intel_tool/tests/test-data/dscan.txt +250 -0
  58. aa_intel_tool/tests/test_admin.py +50 -38
  59. aa_intel_tool/tests/test_helper_eve_character.py +405 -0
  60. aa_intel_tool/tests/test_models.py +188 -4
  61. aa_intel_tool/tests/test_parser_general.py +771 -0
  62. aa_intel_tool/tests/test_parser_module_chatlist.py +154 -0
  63. {aa_intel_tool-2.6.1.dist-info → aa_intel_tool-2.6.3.dist-info}/METADATA +4 -4
  64. {aa_intel_tool-2.6.1.dist-info → aa_intel_tool-2.6.3.dist-info}/RECORD +66 -64
  65. aa_intel_tool/tests/test_parser.py +0 -135
  66. {aa_intel_tool-2.6.1.dist-info → aa_intel_tool-2.6.3.dist-info}/WHEEL +0 -0
  67. {aa_intel_tool-2.6.1.dist-info → aa_intel_tool-2.6.3.dist-info}/licenses/LICENSE +0 -0
@@ -2,18 +2,106 @@
2
2
  Tests for our models
3
3
  """
4
4
 
5
+ # Standard Library
6
+ from unittest.mock import patch
7
+
5
8
  # Django
9
+ from django.db import IntegrityError
6
10
  from django.test import TestCase
7
11
 
8
12
  # AA Intel Tool
9
- from aa_intel_tool.models import Scan
13
+ from aa_intel_tool.models import Scan, ScanData
10
14
 
11
15
 
12
- class TestScan(TestCase):
16
+ class TestScanModel(TestCase):
13
17
  """
14
- Tests for the board model
18
+ Test the Scan model
15
19
  """
16
20
 
21
+ def test_generates_unique_hash(self):
22
+ """
23
+ Test that the hash is unique
24
+
25
+ :return:
26
+ :rtype:
27
+ """
28
+
29
+ hash1 = Scan.generate_scan_hash()
30
+ hash2 = Scan.generate_scan_hash()
31
+
32
+ self.assertNotEqual(hash1, hash2)
33
+
34
+ def test_generates_hash_of_correct_length(self):
35
+ """
36
+ Test that the hash is of the correct length
37
+
38
+ :return:
39
+ :rtype:
40
+ """
41
+
42
+ scan_hash = Scan.generate_scan_hash()
43
+
44
+ self.assertEqual(len(scan_hash), 30)
45
+
46
+ def test_generates_hash_not_in_database(self):
47
+ """
48
+ Test that the generated hash is not in the database
49
+
50
+ :return:
51
+ :rtype:
52
+ """
53
+
54
+ existing_scan = Scan.objects.create(raw_data="test data")
55
+ scan_hash = Scan.generate_scan_hash()
56
+
57
+ self.assertNotEqual(scan_hash, existing_scan.hash)
58
+
59
+ def test_handles_collision_by_generating_new_hash(self):
60
+ """
61
+ Test that the hash collision is handled by generating a new hash
62
+
63
+ :return:
64
+ :rtype:
65
+ """
66
+
67
+ with patch("aa_intel_tool.models.Scan.objects.filter") as mock_filter:
68
+ # Simulate hash collision by returning True for the first two calls
69
+ mock_filter.return_value.exists.side_effect = [True, True, False]
70
+
71
+ new_hash = Scan.generate_scan_hash()
72
+
73
+ self.assertIsNotNone(new_hash)
74
+ self.assertEqual(len(new_hash), 30)
75
+ self.assertNotIn(new_hash, ["collision_hash1", "collision_hash2"])
76
+
77
+ def test_saves_with_generated_hash(self):
78
+ """
79
+ Test that the hash is generated on save
80
+
81
+ :return:
82
+ :rtype:
83
+ """
84
+
85
+ scan = Scan(raw_data="test data")
86
+ scan.save()
87
+
88
+ self.assertIsNotNone(scan.hash)
89
+ self.assertEqual(len(scan.hash), 30)
90
+
91
+ def test_generates_new_hash_if_empty_on_save(self):
92
+ """
93
+ Test that a new hash is generated if the hash is empty on save
94
+
95
+ :return:
96
+ :rtype:
97
+ """
98
+
99
+ scan = Scan(hash="", raw_data="test data")
100
+ scan.save()
101
+
102
+ self.assertNotEqual(scan.hash, "")
103
+ self.assertEqual(len(scan.hash), 30)
104
+
17
105
  def test_model_string_names(self):
18
106
  """
19
107
  Test model string name
@@ -27,15 +115,111 @@ class TestScan(TestCase):
27
115
  )
28
116
  scan.save()
29
117
  expected_hash = scan.hash
118
+
30
119
  self.assertEqual(first=str(scan), second=expected_hash)
31
120
 
32
121
  scan.raw_data = "BarFoo"
33
122
  scan.save()
123
+
34
124
  self.assertEqual(first=str(scan), second=expected_hash)
35
125
 
36
126
  scan.hash = ""
37
127
  scan.save()
128
+
38
129
  self.assertNotEqual(first=str(scan), second="")
39
130
  self.assertNotEqual(first=str(scan), second=expected_hash)
40
131
 
41
- scan.save()
132
+
133
+ class TestScanDataModel(TestCase):
134
+ """
135
+ Test the ScanData model
136
+ """
137
+
138
+ def test_creates_scan_data_with_valid_section(self):
139
+ """
140
+ Test that the ScanData model can be created with a valid section
141
+
142
+ :return:
143
+ :rtype:
144
+ """
145
+
146
+ scan = Scan.objects.create(raw_data="test data")
147
+ scan_data = ScanData.objects.create(
148
+ scan=scan,
149
+ section=ScanData.Section.PILOTLIST,
150
+ processed_data={"key": "value"},
151
+ )
152
+
153
+ self.assertEqual(scan_data.section, ScanData.Section.PILOTLIST)
154
+ self.assertEqual(scan_data.processed_data, {"key": "value"})
155
+
156
+ def test_defaults_to_invalid_section(self):
157
+ """
158
+ Test that the ScanData model defaults to INVALID section if not specified
159
+
160
+ :return:
161
+ :rtype:
162
+ """
163
+
164
+ scan = Scan.objects.create(raw_data="test data")
165
+ scan_data = ScanData.objects.create(scan=scan, processed_data={"key": "value"})
166
+
167
+ self.assertEqual(scan_data.section, ScanData.Section.INVALID)
168
+
169
+ def test_allows_null_scan(self):
170
+ """
171
+ Test that the ScanData model allows null scan
172
+
173
+ :return:
174
+ :rtype:
175
+ """
176
+
177
+ scan_data = ScanData.objects.create(
178
+ section=ScanData.Section.PILOTLIST, processed_data={"key": "value"}
179
+ )
180
+
181
+ self.assertIsNone(scan_data.scan)
182
+
183
+ def test_enforces_unique_together_constraint(self):
184
+ """
185
+ Test that the ScanData model enforces unique together constraint on scan and section and raises IntegrityError
186
+
187
+ :return:
188
+ :rtype:
189
+ """
190
+
191
+ scan = Scan.objects.create(raw_data="test data")
192
+ ScanData.objects.create(
193
+ scan=scan,
194
+ section=ScanData.Section.PILOTLIST,
195
+ processed_data={"key": "value"},
196
+ )
197
+
198
+ with self.assertRaises(IntegrityError):
199
+ ScanData.objects.create(
200
+ scan=scan,
201
+ section=ScanData.Section.PILOTLIST,
202
+ processed_data={"key": "another value"},
203
+ )
204
+
205
+ def test_allows_different_sections_for_same_scan(self):
206
+ """
207
+ Test that the ScanData model allows different sections for the same scan
208
+
209
+ :return:
210
+ :rtype:
211
+ """
212
+
213
+ scan = Scan.objects.create(raw_data="test data")
214
+ scan_data1 = ScanData.objects.create(
215
+ scan=scan,
216
+ section=ScanData.Section.PILOTLIST,
217
+ processed_data={"key": "value"},
218
+ )
219
+ scan_data2 = ScanData.objects.create(
220
+ scan=scan,
221
+ section=ScanData.Section.CORPORATIONLIST,
222
+ processed_data={"key": "value"},
223
+ )
224
+
225
+ self.assertNotEqual(scan_data1.section, scan_data2.section)