Skip to content

Commit

Permalink
Add tests for term-id
Browse files Browse the repository at this point in the history
- Tests reflect the allowed characters of term subjects (term ids)
  • Loading branch information
FelixFrizzy committed Jan 10, 2025
1 parent dc6eaeb commit f6b5d11
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions evoks/tests/views/test_vocabulary_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def test_overview_search(self):
# create term so that search finds something
self.c.post(
'/vocabularies/{0}/terms'.format(self.vocabulary.name),
{'create-term': '', 'term-subject': 'testterm', 'term-label': 'testlabel'}
{'create-term': '', 'term-subject': 'testterm_43-2_23', 'term-label': 'testlabel'}
)

response = self.c.get(
Expand Down Expand Up @@ -502,20 +502,41 @@ def test_terms_view_add_term(self):
def test_create_term(self):
response = self.c.post(
'/vocabularies/{0}/terms'.format(self.vocabulary.name),
{'create-term': '', 'term-subject': 'testterm', 'term-label': 'testlabel'},
{'create-term': '', 'term-subject': 'testterm_43-2_23', 'term-label': 'testlabel'},
follow=True
)
self.assertEqual(response.status_code, 200)
voc = Vocabulary.objects.get(name=self.vocabulary.name)
self.assertTrue(voc.term_set.filter(name='testterm').exists())
self.assertTrue(voc.term_set.filter(name='testterm_43-2_23').exists())

# create same term again
error_response = self.c.post(
'/vocabularies/{0}/terms'.format(self.vocabulary.name),
{'create-term': '', 'term-subject': 'testterm', 'term-label': 'testlabel'}
{'create-term': '', 'term-subject': 'testterm_43-2_23', 'term-label': 'testlabel'}
)
self.assertEqual(error_response.status_code, 409)

# create term with empty subject
error_response = self.c.post(
'/vocabularies/{0}/terms'.format(self.vocabulary.name),
{'create-term': '', 'term-subject': '', 'term-label': 'testlabelempty'}
)
self.assertEqual(error_response.status_code, 400)

# create term with space in subject
error_response = self.c.post(
'/vocabularies/{0}/terms'.format(self.vocabulary.name),
{'create-term': '', 'term-subject': 'test term', 'term-label': 'testlabelspace'}
)
self.assertEqual(error_response.status_code, 400)

# create term with disallowed character in subject
error_response = self.c.post(
'/vocabularies/{0}/terms'.format(self.vocabulary.name),
{'create-term': '', 'term-subject': 'testterm!', 'term-label': 'testlabelquestionmark'}
)
self.assertEqual(error_response.status_code, 400)

# base view tests

def test_base_view(self):
Expand Down Expand Up @@ -571,7 +592,7 @@ def test_base_search(self):
# create term so that search finds something
self.c.post(
'/vocabularies/{0}/terms'.format(self.vocabulary.name),
{'create-term': '', 'term-subject': 'testterm', 'term-label': 'testlabel'}
{'create-term': '', 'term-subject': 'testterm_43-2_23', 'term-label': 'testlabel'}
)

response = self.c.get(
Expand Down

0 comments on commit f6b5d11

Please sign in to comment.