def test_checks_youtube_must_return_200(self, patched_head):
     """
     Tests that the Youtube ID is tested.
     """
     patched_head.return_value.status_code = 404
     data = {'youtube_id': '_IMlaimDzTg'}
     form = YoutubeVideoForm(data)
     self.assertFalse(form.is_valid())
     self.assertEquals(form.errors['youtube_id'], ['Could not read Youtube API.'])
Exemplo n.º 2
0
 def test_checks_youtube_must_return_200(self, patched_head):
     """
     Tests that the Youtube ID is tested.
     """
     patched_head.return_value.status_code = 404
     data = {'youtube_id': '_IMlaimDzTg'}
     form = YoutubeVideoForm(data)
     self.assertFalse(form.is_valid())
     self.assertEquals(form.errors['youtube_id'],
                       ['Could not read Youtube API.'])
 def test_checks_valid_youtube_id(self, patched_head):
     """
     Tests that the Youtube ID is tested.
     """
     patched_head.return_value.status_code = 200
     patched_head.return_value.json.return_value = {'pageInfo': {'totalResults': 0}}
     data = {'youtube_id': '_IMlaimDzTg'}
     form = YoutubeVideoForm(data)
     self.assertFalse(form.is_valid())
     self.assertEquals(
         form.errors['youtube_id'],
         ['Unable to access a YouTube video with that ID. Please try again.']
     )
Exemplo n.º 4
0
 def test_checks_valid_youtube_id(self, patched_head):
     """
     Tests that the Youtube ID is tested.
     """
     patched_head.return_value.status_code = 200
     patched_head.return_value.json.return_value = {
         'pageInfo': {
             'totalResults': 0
         }
     }
     data = {'youtube_id': '_IMlaimDzTg'}
     form = YoutubeVideoForm(data)
     self.assertFalse(form.is_valid())
     self.assertEquals(form.errors['youtube_id'], [
         'Unable to access a YouTube video with that ID. Please try again.'
     ])