示例#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"}')
示例#2
0
 def test_invalid_json_singular(self):
     "Test that invalid JSON trips the singluar validator"
     with self.assertRaises(TextbookValidationError):
         validate_textbook_json("[{1]}")
示例#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!"}]')
示例#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)
示例#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))
示例#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)
示例#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)
示例#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!"}]')
示例#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"}')
示例#10
0
 def test_invalid_json_singular(self):
     "Test that invalid JSON trips the singluar validator"
     with self.assertRaises(TextbookValidationError):
         validate_textbook_json("[{1]}")
示例#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))
示例#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)
示例#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)
示例#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)