aa-structures 2.2.0__py3-none-any.whl → 2.3.1b1__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 (29) hide show
  1. {aa_structures-2.2.0.dist-info → aa_structures-2.3.1b1.dist-info}/METADATA +1 -1
  2. {aa_structures-2.2.0.dist-info → aa_structures-2.3.1b1.dist-info}/RECORD +28 -23
  3. {aa_structures-2.2.0.dist-info → aa_structures-2.3.1b1.dist-info}/WHEEL +1 -1
  4. structures/__init__.py +1 -1
  5. structures/admin.py +13 -13
  6. structures/core/notification_embeds.py +47 -47
  7. structures/locale/de/LC_MESSAGES/django.po +314 -305
  8. structures/locale/django.pot +2227 -0
  9. structures/locale/en/LC_MESSAGES/django.po +312 -305
  10. structures/locale/es/LC_MESSAGES/django.po +314 -305
  11. structures/locale/fr_FR/LC_MESSAGES/django.po +2227 -0
  12. structures/locale/it_IT/LC_MESSAGES/django.po +2227 -0
  13. structures/locale/ja/LC_MESSAGES/django.po +2228 -0
  14. structures/locale/ko_KR/LC_MESSAGES/django.po +2227 -0
  15. structures/locale/ru/LC_MESSAGES/django.po +312 -305
  16. structures/locale/uk/LC_MESSAGES/django.po +2231 -0
  17. structures/locale/zh_Hans/LC_MESSAGES/django.po +314 -305
  18. structures/managers.py +12 -12
  19. structures/models/notifications.py +20 -17
  20. structures/models/owners.py +1 -3
  21. structures/models/structures.py +1 -1
  22. structures/tests/core/test_notification_embeds.py +125 -36
  23. structures/tests/models/test_notifications_1.py +38 -12
  24. structures/tests/test_admin.py +48 -22
  25. structures/tests/test_integration.py +88 -1
  26. structures/tests/testdata/factories_2.py +34 -1
  27. structures/views.py +3 -2
  28. structures/tests/core/test_notification_embeds_2.py +0 -78
  29. {aa_structures-2.2.0.dist-info → aa_structures-2.3.1b1.dist-info}/licenses/LICENSE +0 -0
structures/managers.py CHANGED
@@ -1,6 +1,6 @@
1
1
  import datetime as dt
2
2
  import itertools
3
- from typing import Optional, Set, Tuple
3
+ from typing import Optional, Set, Tuple, TypeVar
4
4
 
5
5
  from django.contrib.auth.models import User
6
6
  from django.db import models, transaction
@@ -21,6 +21,8 @@ from .webhooks.managers import WebhookBaseManager
21
21
 
22
22
  logger = LoggerAddTag(get_extension_logger(__name__), __title__)
23
23
 
24
+ ModelType = TypeVar("ModelType", bound=models.Model)
25
+
24
26
 
25
27
  class EveSovereigntyMapManager(models.Manager):
26
28
  def update_from_esi(self):
@@ -53,7 +55,7 @@ class EveSovereigntyMapManager(models.Manager):
53
55
  self.bulk_create(obj_list, batch_size=1000)
54
56
 
55
57
  def corporation_has_sov(
56
- self, eve_solar_system: models.Model, corporation: EveCorporationInfo
58
+ self, eve_solar_system, corporation: EveCorporationInfo
57
59
  ) -> bool:
58
60
  """returns true if given corporation has sov in this solar system
59
61
  else False
@@ -68,9 +70,7 @@ class EveSovereigntyMapManager(models.Manager):
68
70
  self.solar_system_sov_alliance_id(eve_solar_system) == alliance_id
69
71
  )
70
72
 
71
- def solar_system_sov_alliance_id(
72
- self, eve_solar_system: models.Model
73
- ) -> Optional[int]:
73
+ def solar_system_sov_alliance_id(self, eve_solar_system) -> Optional[int]:
74
74
  """returns ID of sov owning alliance for this system or None"""
75
75
  if not eve_solar_system.is_null_sec:
76
76
  return None
@@ -133,7 +133,7 @@ class GeneratedNotificationQuerySet(NotificationBaseQuerySet):
133
133
  class GeneratedNotificationManagerBase(NotificationBaseManagerBase):
134
134
  def get_or_create_from_structure(
135
135
  self, structure: models.Model, notif_type: models.TextChoices
136
- ) -> Tuple[models.Model, bool]:
136
+ ) -> Tuple[ModelType, bool]:
137
137
  """Get or create an object from given structure."""
138
138
  from .models import NotificationType
139
139
 
@@ -142,9 +142,7 @@ class GeneratedNotificationManagerBase(NotificationBaseManagerBase):
142
142
 
143
143
  return self._get_or_create_tower_reinforced(structure)
144
144
 
145
- def _get_or_create_tower_reinforced(
146
- self, structure: models.Model
147
- ) -> Tuple[models.Model, bool]:
145
+ def _get_or_create_tower_reinforced(self, structure) -> Tuple[ModelType, bool]:
148
146
  from .models import NotificationType
149
147
 
150
148
  if not structure.is_starbase:
@@ -233,7 +231,9 @@ class StructureQuerySet(models.QuerySet):
233
231
  )
234
232
 
235
233
  # TODO: Add specific tests
236
- def visible_for_user(self, user: User, tags: list = None) -> models.QuerySet:
234
+ def visible_for_user(
235
+ self, user: User, tags: Optional[list] = None
236
+ ) -> models.QuerySet:
237
237
  if user.has_perm("structures.view_all_structures"):
238
238
  structures_query = self.select_related_defaults()
239
239
  if tags:
@@ -247,7 +247,7 @@ class StructureQuerySet(models.QuerySet):
247
247
  ):
248
248
  corporation_ids = {
249
249
  character_ownership.character.corporation_id
250
- for character_ownership in user.character_ownerships.all()
250
+ for character_ownership in user.character_ownerships.all() # type: ignore
251
251
  }
252
252
  corporations = list(
253
253
  EveCorporationInfo.objects.select_related("alliance").filter(
@@ -462,7 +462,7 @@ class StructureTagManager(models.Manager):
462
462
  return self.update_or_create_for_space_type(solar_system)
463
463
  return None, None
464
464
 
465
- def update_or_create_for_space_type(self, solar_system: object) -> tuple:
465
+ def update_or_create_for_space_type(self, solar_system) -> tuple:
466
466
  from .models import EveSpaceType
467
467
 
468
468
  space_type = EveSpaceType.from_solar_system(solar_system)
@@ -1,7 +1,7 @@
1
1
  """Notification related models."""
2
2
 
3
3
  import math
4
- from typing import Optional, Tuple, Union
4
+ from typing import List, Optional, Set, Tuple, Union
5
5
 
6
6
  import dhooks_lite
7
7
  import yaml
@@ -177,11 +177,11 @@ class NotificationType(models.TextChoices):
177
177
  )
178
178
 
179
179
  @classproperty
180
- def esi_notifications(cls) -> set:
181
- return set(cls.values) - cls.generated_notifications
180
+ def esi_notifications(cls) -> Set["NotificationType"]:
181
+ return set(cls.values) - cls.generated_notifications # type: ignore
182
182
 
183
183
  @classproperty
184
- def generated_notifications(cls) -> set:
184
+ def generated_notifications(cls) -> Set["NotificationType"]:
185
185
  return {
186
186
  cls.STRUCTURE_JUMP_FUEL_ALERT,
187
187
  cls.STRUCTURE_REFUELED_EXTRA,
@@ -190,7 +190,7 @@ class NotificationType(models.TextChoices):
190
190
  }
191
191
 
192
192
  @classproperty
193
- def webhook_defaults(cls) -> list:
193
+ def webhook_defaults(cls) -> List["NotificationType"]:
194
194
  """List of default notifications for new webhooks."""
195
195
  return [
196
196
  cls.STRUCTURE_ANCHORING,
@@ -212,7 +212,7 @@ class NotificationType(models.TextChoices):
212
212
  ]
213
213
 
214
214
  @classproperty
215
- def relevant_for_timerboard(cls) -> set:
215
+ def relevant_for_timerboard(cls) -> Set["NotificationType"]:
216
216
  """Notification types that can create timers."""
217
217
  return {
218
218
  cls.STRUCTURE_LOST_SHIELD,
@@ -225,7 +225,7 @@ class NotificationType(models.TextChoices):
225
225
  }
226
226
 
227
227
  @classproperty
228
- def relevant_for_alliance_level(cls) -> set:
228
+ def relevant_for_alliance_level(cls) -> Set["NotificationType"]:
229
229
  """Notification types that require the alliance level flag."""
230
230
  return {
231
231
  # billing
@@ -239,7 +239,7 @@ class NotificationType(models.TextChoices):
239
239
  cls.SOV_STRUCTURE_REINFORCED,
240
240
  cls.SOV_STRUCTURE_DESTROYED,
241
241
  cls.SOV_ALL_CLAIM_LOST_MSG,
242
- cls.SOV_ALL_ANCHORING_MSG,
242
+ # cls.SOV_ALL_ANCHORING_MSG, # This notif is not broadcasted to all corporations
243
243
  # wars
244
244
  cls.WAR_ALLY_JOINED_WAR_AGGRESSOR_MSG,
245
245
  cls.WAR_ALLY_JOINED_WAR_AllY_MSG,
@@ -255,7 +255,7 @@ class NotificationType(models.TextChoices):
255
255
  }
256
256
 
257
257
  @classproperty
258
- def relevant_for_moonmining(cls) -> set:
258
+ def relevant_for_moonmining(cls) -> Set["NotificationType"]:
259
259
  """Notification types about moon mining."""
260
260
  return {
261
261
  cls.MOONMINING_EXTRACTION_STARTED,
@@ -266,7 +266,7 @@ class NotificationType(models.TextChoices):
266
266
  }
267
267
 
268
268
  @classproperty
269
- def structure_related(cls) -> set:
269
+ def structure_related(cls) -> Set["NotificationType"]:
270
270
  """Notification types that are related to a structure."""
271
271
  return {
272
272
  cls.STRUCTURE_ONLINE,
@@ -298,18 +298,18 @@ class NotificationType(models.TextChoices):
298
298
  }
299
299
 
300
300
  @classproperty
301
- def relevant_for_forwarding(cls) -> set:
301
+ def relevant_for_forwarding(cls) -> Set["NotificationType"]:
302
302
  """Notification types that are forwarded to Discord."""
303
- my_set = set(cls.values_enabled)
303
+ my_set = set(cls.values_enabled) # type: ignore
304
304
  # if STRUCTURES_NOTIFICATION_DISABLE_ESI_FUEL_ALERTS:
305
305
  # my_set.discard(cls.STRUCTURE_FUEL_ALERT)
306
306
  # my_set.discard(cls.TOWER_RESOURCE_ALERT_MSG)
307
307
  return my_set
308
308
 
309
309
  @classproperty
310
- def values_enabled(cls) -> set:
310
+ def values_enabled(cls) -> Set["NotificationType"]:
311
311
  """Values of enabled notif types only."""
312
- my_set = set(cls.values)
312
+ my_set = set(cls.values) # type: ignore
313
313
  if not STRUCTURES_FEATURE_REFUELED_NOTIFICATIONS:
314
314
  my_set.discard(cls.STRUCTURE_REFUELED_EXTRA)
315
315
  my_set.discard(cls.TOWER_REFUELED_EXTRA)
@@ -514,10 +514,13 @@ class NotificationBase(models.Model):
514
514
  def relevant_webhooks(self) -> models.QuerySet:
515
515
  """Determine relevant webhooks matching this notification type."""
516
516
  if not self.is_structure_related:
517
- structures_qs = None
517
+ structures_qs = Structure.objects.none()
518
518
  else:
519
519
  structures_qs = self.calc_related_structures()
520
- if structures_qs and structures_qs.filter(webhooks__isnull=False).count() == 1:
520
+ if (
521
+ structures_qs.exists()
522
+ and structures_qs.filter(webhooks__isnull=False).count() == 1
523
+ ):
521
524
  webhooks_qs = structures_qs.first().webhooks.filter(
522
525
  notification_types__contains=self.notif_type, is_active=True
523
526
  )
@@ -631,7 +634,7 @@ class NotificationBase(models.Model):
631
634
 
632
635
  def _generate_embed(
633
636
  self, language_code: Optional[str]
634
- ) -> Tuple[dhooks_lite.Embed, Webhook.PingType]:
637
+ ) -> Tuple[dhooks_lite.Embed, Optional[Webhook.PingType]]:
635
638
  """Generates a Discord embed for this notification."""
636
639
  from ..core.notification_embeds import NotificationBaseEmbed
637
640
 
@@ -905,9 +905,7 @@ class Owner(models.Model):
905
905
  names = {x["item_id"]: x["name"] for x in names_data}
906
906
  return names
907
907
 
908
- def _update_starbase_detail(
909
- self, structure: object, token: Token
910
- ) -> StarbaseDetail:
908
+ def _update_starbase_detail(self, structure, token: Token) -> StarbaseDetail:
911
909
  """Update detail for the starbase from ESI."""
912
910
  operation = esi.client.Corporation.get_corporations_corporation_id_starbases_starbase_id(
913
911
  corporation_id=structure.owner.corporation.corporation_id,
@@ -1009,7 +1009,7 @@ class StarbaseDetail(models.Model):
1009
1009
  def __str__(self) -> str:
1010
1010
  return str(self.structure)
1011
1011
 
1012
- def calc_fuel_expires(self) -> dt.datetime:
1012
+ def calc_fuel_expires(self) -> Optional[dt.datetime]:
1013
1013
  """Estimate when fuel will expire for this starbase.
1014
1014
 
1015
1015
  Estimate will vary due to server caching of remaining fuel blocks.
@@ -8,13 +8,30 @@ from eveuniverse.models import EveEntity
8
8
 
9
9
  from app_utils.testing import NoSocketsTestCase, create_user_from_evecharacter
10
10
 
11
- from ...core import notification_embeds as ne
12
- from ...models.notifications import Notification, NotificationType, Structure, Webhook
11
+ from structures.core import notification_embeds as ne
12
+ from structures.core.notification_embeds import (
13
+ NotificationBaseEmbed,
14
+ NotificationTowerReinforcedExtra,
15
+ )
16
+ from structures.models.notifications import (
17
+ Notification,
18
+ NotificationType,
19
+ Structure,
20
+ Webhook,
21
+ )
22
+
13
23
  from ..testdata.factories import (
14
24
  create_notification,
15
25
  create_owner_from_user,
16
26
  create_starbase,
17
27
  )
28
+ from ..testdata.factories_2 import (
29
+ EveEntityAllianceFactory,
30
+ GeneratedNotificationFactory,
31
+ NotificationFactory,
32
+ OwnerFactory,
33
+ WebhookFactory,
34
+ )
18
35
  from ..testdata.helpers import (
19
36
  create_structures,
20
37
  load_entities,
@@ -27,6 +44,16 @@ from ..testdata.load_eveuniverse import load_eveuniverse
27
44
  MODULE_PATH = "structures.core.notification_embeds"
28
45
 
29
46
 
47
+ class TestBilType(TestCase):
48
+ def test_should_create_from_valid_id(self):
49
+ self.assertEqual(ne.BillType.to_enum(7), ne.BillType.INFRASTRUCTURE_HUB)
50
+
51
+ def test_should_create_from_invalid_id(self):
52
+ for bill_id in range(7):
53
+ with self.subTest(bill_id=bill_id):
54
+ self.assertEqual(ne.BillType.to_enum(bill_id), ne.BillType.UNKNOWN)
55
+
56
+
30
57
  class TestNotificationEmbeds(TestCase):
31
58
  @classmethod
32
59
  def setUpClass(cls):
@@ -35,10 +62,6 @@ class TestNotificationEmbeds(TestCase):
35
62
  create_structures()
36
63
  _, cls.owner = set_owner_character(character_id=1001)
37
64
  load_notification_entities(cls.owner)
38
- cls.webhook = Webhook.objects.create(
39
- name="Test", url="http://www.example.com/dummy/"
40
- )
41
- cls.owner.webhooks.add(cls.webhook)
42
65
 
43
66
  def test_should_create_obj_from_notification(self):
44
67
  # given
@@ -59,6 +82,40 @@ class TestNotificationEmbeds(TestCase):
59
82
  "notif_type='MoonminingExtractionFinished'))",
60
83
  )
61
84
 
85
+ def test_should_raise_exception_for_unsupported_notif_types(self):
86
+ # given
87
+ notification = Notification.objects.create(
88
+ notification_id=666,
89
+ owner=self.owner,
90
+ sender=EveEntity.objects.get(id=2001),
91
+ timestamp=now(),
92
+ notif_type="XXXUnsupportedNotificationTypeXXX",
93
+ last_updated=now(),
94
+ )
95
+ # when / then
96
+ with self.assertRaises(NotImplementedError):
97
+ ne.NotificationBaseEmbed.create(notification)
98
+
99
+ def test_should_require_notification_for_init(self):
100
+ with self.assertRaises(TypeError):
101
+ ne.NotificationBaseEmbed(notification="dummy")
102
+
103
+ def test_should_require_notification_for_factory(self):
104
+ with self.assertRaises(TypeError):
105
+ ne.NotificationBaseEmbed.create(notification="dummy")
106
+
107
+
108
+ class TestNotificationEmbedsGenerate(TestCase):
109
+ @classmethod
110
+ def setUpClass(cls):
111
+ super().setUpClass()
112
+ load_eveuniverse()
113
+ create_structures()
114
+ _, cls.owner = set_owner_character(character_id=1001)
115
+ load_notification_entities(cls.owner)
116
+ cls.webhook = WebhookFactory()
117
+ cls.owner.webhooks.add(cls.webhook)
118
+
62
119
  def test_should_generate_embed_from_notification(self):
63
120
  # given
64
121
  notification = Notification.objects.get(notification_id=1000000403)
@@ -116,36 +173,6 @@ class TestNotificationEmbeds(TestCase):
116
173
  types_tested.add(notification.notif_type)
117
174
  self.assertSetEqual(NotificationType.esi_notifications, types_tested)
118
175
 
119
- def test_should_raise_exception_for_unsupported_notif_types(self):
120
- # given
121
- notification = Notification.objects.create(
122
- notification_id=666,
123
- owner=self.owner,
124
- sender=EveEntity.objects.get(id=2001),
125
- timestamp=now(),
126
- notif_type="XXXUnsupportedNotificationTypeXXX",
127
- last_updated=now(),
128
- )
129
- # when / then
130
- with self.assertRaises(NotImplementedError):
131
- ne.NotificationBaseEmbed.create(notification)
132
-
133
- def test_should_require_notification_for_init(self):
134
- with self.assertRaises(TypeError):
135
- ne.NotificationBaseEmbed(notification="dummy")
136
-
137
- def test_should_require_notification_for_factory(self):
138
- with self.assertRaises(TypeError):
139
- ne.NotificationBaseEmbed.create(notification="dummy")
140
-
141
- def test_should_not_allow_generating_embed_for_base_class(self):
142
- # given
143
- notification = Notification.objects.get(notification_id=1000000403)
144
- notification_embed = ne.NotificationBaseEmbed(notification=notification)
145
- # when
146
- with self.assertRaises(ValueError):
147
- notification_embed.generate_embed()
148
-
149
176
  def test_should_set_ping_everyone_for_color_danger(self):
150
177
  # given
151
178
  notification = Notification.objects.get(notification_id=1000000513)
@@ -269,3 +296,65 @@ class TestNotificationEmbedsClasses(NoSocketsTestCase):
269
296
  # then
270
297
  description = markdown_to_plain(discord_embed.description)
271
298
  self.assertIn("is running out of fuel in 2 hours", description)
299
+
300
+
301
+ class TestGeneratedNotification(NoSocketsTestCase):
302
+ @classmethod
303
+ def setUpClass(cls):
304
+ super().setUpClass()
305
+ load_eveuniverse()
306
+
307
+ def test_should_create_tower_reinforced_embed(self):
308
+ # given
309
+ notif = GeneratedNotificationFactory()
310
+ # when
311
+ obj = NotificationBaseEmbed.create(notif)
312
+ # then
313
+ self.assertIsInstance(obj, NotificationTowerReinforcedExtra)
314
+
315
+ def test_should_generate_embed(self):
316
+ # given
317
+ notif = GeneratedNotificationFactory()
318
+ embed = NotificationBaseEmbed.create(notif)
319
+ # when
320
+ obj = embed.generate_embed()
321
+ # then
322
+ self.assertIsInstance(obj, dhooks_lite.Embed)
323
+ starbase = notif.structures.first()
324
+ self.assertIn(starbase.name, obj.description)
325
+
326
+
327
+ class TestEveNotificationEmbeds(NoSocketsTestCase):
328
+ @classmethod
329
+ def setUpClass(cls):
330
+ super().setUpClass()
331
+ load_eveuniverse()
332
+ cls.owner = OwnerFactory()
333
+
334
+ def test_should_create_sov_embed(self):
335
+ # given
336
+ notif = NotificationFactory(
337
+ owner=self.owner,
338
+ sender=EveEntityAllianceFactory(),
339
+ notif_type=NotificationType.SOV_ENTOSIS_CAPTURE_STARTED,
340
+ text_from_dict={"solarSystemID": 30000474, "structureTypeID": 32226},
341
+ )
342
+ embed = NotificationBaseEmbed.create(notif)
343
+ # when
344
+ obj = embed.generate_embed()
345
+ # then
346
+ self.assertIsInstance(obj, dhooks_lite.Embed)
347
+
348
+ def test_should_create_sov_embed_without_sender(self):
349
+ # given
350
+ notif = NotificationFactory(
351
+ owner=self.owner,
352
+ sender=None,
353
+ notif_type=NotificationType.SOV_ENTOSIS_CAPTURE_STARTED,
354
+ text_from_dict={"solarSystemID": 30000474, "structureTypeID": 32226},
355
+ )
356
+ embed = NotificationBaseEmbed.create(notif)
357
+ # when
358
+ obj = embed.generate_embed()
359
+ # then
360
+ self.assertIsInstance(obj, dhooks_lite.Embed)
@@ -121,47 +121,73 @@ class TestNotificationFilterForAllianceLevel(NoSocketsTestCase):
121
121
  # given
122
122
  self.owner.is_alliance_main = False
123
123
  self.owner.save()
124
- notif = self.owner.notification_set.get(notification_id=1000000509)
124
+ notifs = self.owner.notification_set.exclude(
125
+ notif_type__in=NotificationType.relevant_for_alliance_level
126
+ )
125
127
  # when/then
126
- self.assertFalse(notif.filter_for_alliance_level())
128
+ for notif in notifs:
129
+ with self.subTest(notif=str(notif)):
130
+ self.assertFalse(notif.filter_for_alliance_level())
127
131
 
128
132
  def test_should_not_filter_non_alliance_notifications_2(self):
129
133
  # given
130
134
  self.owner.is_alliance_main = True
131
135
  self.owner.save()
132
- notif = self.owner.notification_set.get(notification_id=1000000509)
136
+ notifs = self.owner.notification_set.exclude(
137
+ notif_type__in=NotificationType.relevant_for_alliance_level
138
+ )
133
139
  # when/then
134
- self.assertFalse(notif.filter_for_alliance_level())
140
+ for notif in notifs:
141
+ with self.subTest(notif=str(notif)):
142
+ self.assertFalse(notif.filter_for_alliance_level())
135
143
 
136
144
  def test_should_filter_alliance_notifications(self):
137
145
  # given
138
146
  self.owner.is_alliance_main = False
139
147
  self.owner.save()
140
- notif = self.owner.notification_set.get(notification_id=1000000803)
148
+ notifs = self.owner.notification_set.filter(
149
+ notif_type__in=NotificationType.relevant_for_alliance_level
150
+ )
141
151
  # when/then
142
- self.assertTrue(notif.filter_for_alliance_level())
152
+ for notif in notifs:
153
+ with self.subTest(notif=str(notif)):
154
+ self.assertTrue(notif.filter_for_alliance_level())
143
155
 
144
156
  def test_should_not_filter_alliance_notifications_1(self):
145
157
  # given
146
158
  self.owner.is_alliance_main = True
147
159
  self.owner.save()
160
+ notifs = self.owner.notification_set.filter(
161
+ notif_type__in=NotificationType.relevant_for_alliance_level
162
+ )
148
163
  # when/then
149
- notif = self.owner.notification_set.get(notification_id=1000000803)
150
- self.assertFalse(notif.filter_for_alliance_level())
164
+ for notif in notifs:
165
+ with self.subTest(notif=str(notif)):
166
+ self.assertFalse(notif.filter_for_alliance_level())
151
167
 
152
168
  def test_should_not_filter_alliance_notifications_2(self):
153
169
  # given
154
170
  self.owner.is_alliance_main = True
155
171
  self.owner.save()
156
- notif = self.owner.notification_set.get(notification_id=1000000803)
157
- self.assertFalse(notif.filter_for_alliance_level())
172
+ notifs = self.owner.notification_set.filter(
173
+ notif_type__in=NotificationType.relevant_for_alliance_level
174
+ )
175
+ # when/then
176
+ for notif in notifs:
177
+ with self.subTest(notif=str(notif)):
178
+ self.assertFalse(notif.filter_for_alliance_level())
158
179
 
159
180
  def test_should_not_filter_alliance_notifications_3(self):
160
181
  # given
161
182
  _, owner = set_owner_character(character_id=1102) # corp with no alliance
162
183
  load_notification_entities(owner)
163
- notif = owner.notification_set.get(notification_id=1000000803)
164
- self.assertFalse(notif.filter_for_alliance_level())
184
+ notifs = self.owner.notification_set.filter(
185
+ notif_type__in=NotificationType.relevant_for_alliance_level
186
+ )
187
+ # when/then
188
+ for notif in notifs:
189
+ with self.subTest(notif=str(notif)):
190
+ self.assertFalse(notif.filter_for_alliance_level())
165
191
 
166
192
 
167
193
  class TestNotificationCreateFromStructure(NoSocketsTestCase):