Skip to content

Commit

Permalink
Update resources unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpirix committed Jun 13, 2024
1 parent cf04262 commit de34ebd
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions qgis-app/geopackages/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def test_upload_acceptable_size_file(self):
"description": "Test upload an acceptable gpkg size",
"thumbnail_image": uploaded_thumbnail,
"file": uploaded_gpkg,
"tags": "gpkg,project,test"
}
response = self.client.post(url, data, follow=True)
# should send email notify
Expand All @@ -166,6 +167,11 @@ def test_upload_acceptable_size_file(self):
)
gpkg = Geopackage.objects.first()
self.assertEqual(gpkg.name, "spiky polygons")
# Check the tags
self.assertEqual(
gpkg.tags.filter(
name__in=['gpkg', 'project', 'test']).count(),
3)
url = reverse("geopackage_detail", kwargs={"pk": gpkg.id})
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
Expand Down
9 changes: 9 additions & 0 deletions qgis-app/layerdefinitions/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,18 @@ def setUp(self):
"thumbnail_image": self.uploaded_thumbnail,
"file": self.uploaded_file,
"license": "license",
"tags": "layerdefinition,test"
}
self.response = self.client.post(url, self.data, follow=True)

def test_tags_wavefront(self):
# Check the tags
qlr = LayerDefinition.objects.first()
self.assertEqual(
qlr.tags.filter(
name__in=['layerdefinition', 'test']).count(),
2)

def test_upload_file_succeed_send_notification(self):
self.assertEqual(self.response.status_code, 200)
# should send email notify
Expand Down
6 changes: 6 additions & 0 deletions qgis-app/models/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,18 @@ def test_upload_acceptable_model3_size_file(self):
"description": "Test upload an acceptable model size",
"thumbnail_image": uploaded_thumbnail,
"file": uploaded_model,
"tags": "model,project,test"
}
response = self.client.post(url, data, follow=True)
# should send email notify
self.assertEqual(len(mail.outbox), 1)
model = Model.objects.first()
self.assertEqual(model.name, "flooded buildings extractor")
# Check the tags
self.assertEqual(
model.tags.filter(
name__in=['model', 'project', 'test']).count(),
3)
url = reverse("model_detail", kwargs={"pk": model.id})
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
Expand Down
7 changes: 7 additions & 0 deletions qgis-app/styles/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def test_upload_xml_file(self):
"file": xml_file,
"thumbnail_image": self.thumbnail,
"description": "This style is for testing only purpose",
"tags": "xml,style,test"
},
)
self.assertEqual(self.response.status_code, 200)
Expand All @@ -85,6 +86,12 @@ def test_upload_xml_file(self):
settings.EMAIL_HOST_USER
)

# Check the tags
self.assertEqual(
Style.objects.get(name='Cat Trail').tags.filter(
name__in=['xml', 'style', 'test']).count(),
3)

# style should be in Waiting Review
url = reverse("style_unapproved")
self.response = self.client.get(url)
Expand Down
8 changes: 8 additions & 0 deletions qgis-app/wavefronts/tests/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,19 @@ def setUp(self):
"description": "Test upload a wavefront",
"thumbnail_image": uploaded_thumbnail,
"file": uploaded_file,
"tags": "3dmodel,wavefront,test"
}
self.client.post(url, data, follow=True)
self.object = Wavefront.objects.first()
self.client.logout()

def test_tags_wavefront(self):
# Check the tags
self.assertEqual(
self.object.tags.filter(
name__in=['3dmodel', 'wavefront', 'test']).count(),
3)

def test_approve_wavefront(self):
login = self.client.login(username="staff", password="password")
self.assertTrue(login)
Expand Down

0 comments on commit de34ebd

Please sign in to comment.