Exemplo n.º 1
0
 def test_duplicate_ids(self):
     "Test that duplicate IDs in the plural validator trips the validator"
     textbooks = [
         {"tab_title": "name one", "url": "one.pdf", "id": 1},
         {"tab_title": "name two", "url": "two.pdf", "id": 1},
     ]
     with self.assertRaises(TextbookValidationError):
         validate_textbooks_json(json.dumps(textbooks))
Exemplo n.º 2
0
 def test_duplicate_ids(self):
     "Test that duplicate IDs in the plural validator trips the validator"
     textbooks = [{
         "tab_title": "name one",
         "url": "one.pdf",
         "id": 1,
     }, {
         "tab_title": "name two",
         "url": "two.pdf",
         "id": 1,
     }]
     with self.assertRaises(TextbookValidationError):
         validate_textbooks_json(json.dumps(textbooks))
Exemplo n.º 3
0
 def test_no_tab_title_plural(self):
     "Test that `tab_title` is required for the plural validator"
     with self.assertRaises(TextbookValidationError):
         validate_textbooks_json('[{"url": "/textbook.pdf"}]')
Exemplo n.º 4
0
 def test_wrong_json_plural(self):
     "Test that a JSON object trips the plural validators (requires a list)"
     with self.assertRaises(TextbookValidationError):
         validate_textbooks_json('{"tab_title": "Hi, mom!"}')
Exemplo n.º 5
0
 def test_invalid_json_plural(self):
     "Test that invalid JSON trips the plural validator"
     with self.assertRaises(TextbookValidationError):
         validate_textbooks_json("[{'abc'}]")
Exemplo n.º 6
0
 def test_happy_path_plural(self):
     "Test that the plural validator works properly"
     result = validate_textbooks_json(json.dumps(self.textbooks))
     self.assertEqual(self.textbooks, result)
Exemplo n.º 7
0
 def test_no_tab_title_plural(self):
     "Test that `tab_title` is required for the plural validator"
     with self.assertRaises(TextbookValidationError):
         validate_textbooks_json('[{"url": "/textbook.pdf"}]')
Exemplo n.º 8
0
 def test_wrong_json_plural(self):
     "Test that a JSON object trips the plural validators (requires a list)"
     with self.assertRaises(TextbookValidationError):
         validate_textbooks_json('{"tab_title": "Hi, mom!"}')
Exemplo n.º 9
0
 def test_invalid_json_plural(self):
     "Test that invalid JSON trips the plural validator"
     with self.assertRaises(TextbookValidationError):
         validate_textbooks_json("[{'abc'}]")
Exemplo n.º 10
0
 def test_happy_path_plural(self):
     "Test that the plural validator works properly"
     result = validate_textbooks_json(json.dumps(self.textbooks))
     self.assertEqual(self.textbooks, result)