Skip to content

Commit

Permalink
Added test to verify that document is uploaded without specifying a t…
Browse files Browse the repository at this point in the history
…itle.
  • Loading branch information
ahmdthr committed Feb 14, 2024
1 parent 91de5c3 commit 8e2d435
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions geonode/documents/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def setUp(self):
self.url = reverse("documents-list")
self.invalid_file_path = f"{settings.PROJECT_ROOT}/tests/data/thesaurus.rdf"
self.valid_file_path = f"{settings.PROJECT_ROOT}/base/fixtures/test_xml.xml"
self.no_title_file_path = f"{settings.PROJECT_ROOT}/base/fixtures/test_sld.sld"

def test_documents(self):
"""
Expand Down Expand Up @@ -142,6 +143,18 @@ def test_creation_should_create_the_doc(self):
self.assertEqual("xml", extension)
self.assertTrue(Document.objects.filter(title="New document for testing").exists())

def test_uploading_doc_without_title(self):
"""
A document should be uploaded without specifying a title
"""
self.client.force_login(self.admin)
payload = {"document": {"metadata_only": True, "file_path": self.no_title_file_path}}
actual = self.client.post(self.url, data=payload, format="json")
self.assertEqual(201, actual.status_code)
extension = actual.json().get("document", {}).get("extension", "")
self.assertEqual("sld", extension)
self.assertTrue(Document.objects.filter(title="test_sld.sld").exists())

def test_file_path_and_doc_path_are_not_returned(self):
"""
If file_path and doc_path should not be visible
Expand Down

0 comments on commit 8e2d435

Please sign in to comment.