Ejemplo n.º 1
0
 def test_no_tab_title_singular(self):
     "Test that `tab_title` is required for the singular validator"
     with self.assertRaises(TextbookValidationError):
         validate_textbook_json('{"url": "/textbook.pdf"}')
Ejemplo n.º 2
0
 def test_invalid_json_singular(self):
     "Test that invalid JSON trips the singluar validator"
     with self.assertRaises(TextbookValidationError):
         validate_textbook_json("[{1]}")
Ejemplo n.º 3
0
 def test_wrong_json_singular(self):
     "Test that a JSON list trips the plural validators (requires an object)"
     with self.assertRaises(TextbookValidationError):
         validate_textbook_json(
             '[{"tab_title": "Hi, mom!"}, {"tab_title": "Hi, dad!"}]')
Ejemplo n.º 4
0
 def test_valid_id(self):
     "Test that a valid ID doesn't trip the validator, and comes out unchanged"
     self.tb1["id"] = 1
     result = validate_textbook_json(json.dumps(self.tb1))
     self.assertEqual(self.tb1, result)
Ejemplo n.º 5
0
 def test_invalid_id(self):
     "Test that an invalid ID trips the validator"
     self.tb1["id"] = "abc"
     with self.assertRaises(TextbookValidationError):
         validate_textbook_json(json.dumps(self.tb1))
Ejemplo n.º 6
0
 def test_happy_path_singular_1(self):
     "Test that the singular validator works properly"
     result = validate_textbook_json(json.dumps(self.tb1))
     self.assertEqual(self.tb1, result)
Ejemplo n.º 7
0
 def test_happy_path_singular_2(self):
     "Test that the singular validator works properly, with different data"
     result = validate_textbook_json(json.dumps(self.tb2))
     self.assertEqual(self.tb2, result)
Ejemplo n.º 8
0
 def test_wrong_json_singular(self):
     "Test that a JSON list trips the plural validators (requires an object)"
     with self.assertRaises(TextbookValidationError):
         validate_textbook_json('[{"tab_title": "Hi, mom!"}, {"tab_title": "Hi, dad!"}]')
Ejemplo n.º 9
0
 def test_no_tab_title_singular(self):
     "Test that `tab_title` is required for the singular validator"
     with self.assertRaises(TextbookValidationError):
         validate_textbook_json('{"url": "/textbook.pdf"}')
Ejemplo n.º 10
0
 def test_invalid_json_singular(self):
     "Test that invalid JSON trips the singluar validator"
     with self.assertRaises(TextbookValidationError):
         validate_textbook_json("[{1]}")
Ejemplo n.º 11
0
 def test_invalid_id(self):
     "Test that an invalid ID trips the validator"
     self.tb1["id"] = "abc"
     with self.assertRaises(TextbookValidationError):
         validate_textbook_json(json.dumps(self.tb1))
Ejemplo n.º 12
0
 def test_valid_id(self):
     "Test that a valid ID doesn't trip the validator, and comes out unchanged"
     self.tb1["id"] = 1
     result = validate_textbook_json(json.dumps(self.tb1))
     self.assertEqual(self.tb1, result)
Ejemplo n.º 13
0
 def test_happy_path_singular_2(self):
     "Test that the singular validator works properly, with different data"
     result = validate_textbook_json(json.dumps(self.tb2))
     self.assertEqual(self.tb2, result)
Ejemplo n.º 14
0
 def test_happy_path_singular_1(self):
     "Test that the singular validator works properly"
     result = validate_textbook_json(json.dumps(self.tb1))
     self.assertEqual(self.tb1, result)