Skip to content

Commit

Permalink
Add tests for validate
Browse files Browse the repository at this point in the history
  • Loading branch information
audiodude committed Jul 16, 2023
1 parent 5051d62 commit 918360b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions wp1/selection/models/petscan_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,24 @@ def test_build_non_200(self, mock_requests_get):
actual = self.builder.build(
'text/tab-separated-values',
url='https://petscan.wmflabs.org.fake/?psid=42')

def test_validate(self):
actual = self.builder.validate(
url='https://petscan.wmflabs.org.fake/?psid=42&format=wiki')
self.assertEqual(('', '', []), actual)

def test_validate_missing_url(self):
actual = self.builder.validate()
self.assertEqual(('', '', ['Missing URL parameter']), actual)

def test_validate_not_a_url(self):
afctual = self.builder.validate(url='http:// foo bar [baz]')
self.assertEqual(
('', 'http:// foo bar [baz]', ['That doesn\'t look like a valid URL.']),
actual)

def test_validate_not_a_petscan_url(self):
afctual = self.builder.validate(url='http://en.wikipedia.org/')
self.assertEqual(
('', 'http://en.wikipedia.org/',
['Only URLs that lead to petscan.wmflabs.org are allowed.']), actual)

0 comments on commit 918360b

Please sign in to comment.