Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
submarcos committed Apr 30, 2024
1 parent df74a3a commit d21b882
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions georiviere/portal/tests/test_serializers/test_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ def test_portal_content(self):
data = self.serializer_portal.data
self.assertSetEqual(set(data.keys()), {'id', 'map', 'name', 'flatpages', 'title', 'description', 'extent',
'max_zoom', 'min_zoom', 'main_color'})
self.assertEqual(len(data['map']['group'][0]['layers']), 6)
self.assertEqual(len(data['map']['group'][0]['layers']), 7)

def test_portal_all_layers_grouped_content(self):
data = self.serializer_portal_layers_all_group.data
self.assertEqual(len(data['map']['group']), 1)
self.assertEqual(data['map']['group'][0]['label'], 'Bar')
self.assertSetEqual(set(data.keys()), {'id', 'map', 'name', 'flatpages', 'title', 'description', 'extent',
'max_zoom', 'min_zoom', 'main_color'})
self.assertEqual(len(data['map']['group'][0]['layers']), 6)
self.assertEqual(len(data['map']['group'][0]['layers']), 7)

def test_portal_without_se_content(self):
data = self.serializer_portal_without_spatial_extent.data
Expand Down
8 changes: 4 additions & 4 deletions georiviere/portal/tests/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ class PortalTest(TestCase):
def test_create_portal(self):
self.assertEqual(0, MapLayer.objects.count())
factories.PortalFactory.create()
self.assertEqual(7, MapLayer.objects.count())
self.assertEqual(8, MapLayer.objects.count())

def test_create_portal_poi_category(self):
POICategoryFactory.create()
self.assertEqual(0, MapLayer.objects.count())
factories.PortalFactory.create()
self.assertEqual(8, MapLayer.objects.count())
self.assertEqual(9, MapLayer.objects.count())

category = POICategoryFactory.create(label="New category")
self.assertEqual(9, MapLayer.objects.count())
self.assertEqual(10, MapLayer.objects.count())

category.delete()

self.assertEqual(8, MapLayer.objects.count())
self.assertEqual(9, MapLayer.objects.count())
7 changes: 4 additions & 3 deletions georiviere/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ def test_distance_to_source_is_available(self):
self.assertEqual(response.status_code, 200)
self.assertContains(response,
f'''<a data-pk="{Stream.objects.first().pk}" href="/stream/{Stream.objects.first().pk}/"''')
distance = DistanceToSource.objects.get(
distance_to_source = DistanceToSource.objects.filter(
object_id=obj.pk,
content_type=ContentType.objects.get_for_model(obj)
).distance
self.assertContains(response, f'''({round(distance, 1) if distance else 0}&nbsp;m)''')
).first()
self.assertIsNotNone(distance_to_source)
self.assertContains(response, f'''({round(distance_to_source.distance, 1) if distance_to_source.distance else 0}&nbsp;m)''')

0 comments on commit d21b882

Please sign in to comment.