Exemplo n.º 1
0
 def test_should_not_be_able_to_update_frontpage_lists_private(self):
     username = '******'
     playlist = 'tgif'
     sut = f'{self.playlist_url}/private/{username}/{playlist}'
     body = PlaylistModel.create_random_playlist()
     response = self.put_without_auth_header(sut, body)
     self.assertEqual(404, response.status_code)
Exemplo n.º 2
0
 def test_should_not_be_able_to_update_list_that_do_not_exist(self):
     user = HelperClass.random_word_letters_only(40)
     sut = f'{self.playlist_url}/private/{user}/somerandomlist'
     body = PlaylistModel.create_random_playlist()
     response = self.put_without_auth_header(sut, body)
     self.assertEqual(404, response.status_code)
     error_message = response.json()['Error']
     self.assertEqual(error_message, "List could not be found")
Exemplo n.º 3
0
 def test_should_be_able_to_delete_a_created_playlist(self):
     new_user = HelperClass.random_word_letters_only(25)
     new_playlist = HelperClass.random_word_letters_only(25)
     body = PlaylistModel.create_random_playlist()
     sut = f'{self.playlist_url}/private/{new_user}/{new_playlist}'
     self.post_without_auth_header(sut, body)
     resp = self.delete_without_auth_header(sut)
     self.assertEqual(204, resp.status_code)
Exemplo n.º 4
0
 def test_should_be_able_to_create_new_playlist_and_retrieve_it(self):
     new_user = HelperClass.random_word_letters_only(25)
     new_playlist = HelperClass.random_word_letters_only(25)
     body = PlaylistModel.create_random_playlist()
     sut = f'{self.playlist_url}/private/{new_user}/{new_playlist}'
     self.post_without_auth_header(sut, body)
     resp = self.get_without_auth_header(sut)
     self.assertEqual(200, resp.status_code)
     self.assertEqual(resp.json()['result']['user'], new_user.lower())
Exemplo n.º 5
0
 def test_should_not_be_able_to_put_invalid_data_beverage_list(self):
     username = '******'
     playlist = 'playlistname'
     sut = f'{self.playlist_url}/private/{username}/{playlist}'
     body = PlaylistModel.create_random_playlist()
     body['beverages'] = ['beer']
     response = self.put_without_auth_header(sut, body)
     self.assertEqual(400, response.status_code)
     error_message = response.json()['Error']
     meta_message = response.json()['Meta']
     self.assertIsNotNone(error_message)
     self.assertEqual(meta_message['beverages'][0], "min length is 2")
Exemplo n.º 6
0
 def test_should_not_be_able_to_put_invalid_data_user(self):
     new_users = ['%20', 'o']
     for new_user in new_users:
         playlist = 'listname'
         sut = f'{self.playlist_url}/private/{new_user}/{playlist}'
         body = PlaylistModel.create_random_playlist()
         response = self.put_without_auth_header(sut, body)
         self.assertEqual(400, response.status_code)
         error_message = response.json()['Error']
         meta_message = response.json()['Meta']
         self.assertIsNotNone(error_message)
         self.assertEqual(meta_message['user_name'][0], "min length is 3")
Exemplo n.º 7
0
 def test_should_not_be_able_to_post_to_an_invalid_username(self):
     new_users = ['%20', 'o']
     for new_user in new_users:
         new_playlist = HelperClass.random_word_letters_only(25)
         body = PlaylistModel.create_random_playlist()
         sut = f'{self.playlist_url}/private/{new_user}/{new_playlist}'
         response = self.post_without_auth_header(sut, body)
         self.assertEqual(400, response.status_code)
         error_message = response.json()['Error']
         meta_message = response.json()['Meta']
         self.assertIsNotNone(error_message)
         self.assertEqual(meta_message['user_name'][0], "min length is 3")
Exemplo n.º 8
0
 def test_should_not_be_able_to_post_invalid_data_imageurl(self):
     username = '******'
     playlist = 'playlistname'
     sut = f'{self.playlist_url}/private/{username}/{playlist}'
     body = PlaylistModel.create_random_playlist()
     images = ['i', ' ']
     for image in images:
         body['imageUrl'] = image
         response = self.post_without_auth_header(sut, body)
         self.assertEqual(400, response.status_code)
         error_message = response.json()['Error']
         meta_message = response.json()['Meta']
         self.assertIsNotNone(error_message)
         self.assertEqual(meta_message['imageUrl'][0], "min length is 3")
Exemplo n.º 9
0
 def test_should_be_able_to_put_a_created_user(self):
     new_user = HelperClass.random_word_letters_only(25)
     new_playlist = HelperClass.random_word_letters_only(25)
     body = PlaylistModel.create_random_playlist()
     sut = f'{self.playlist_url}/private/{new_user}/{new_playlist}'
     self.post_without_auth_header(sut, body)
     body['beverages'] = ['beer', 'beer', 'beer']
     new_display_name = 'newDisplayName'
     body['displayName'] = new_display_name
     resp = self.put_without_auth_header(sut, body)
     self.assertEqual(204, resp.status_code)
     response = self.get_without_auth_header(sut)
     json_body = response.json()['result']
     self.assertEqual(200, response.status_code)
     self.assertEqual(new_display_name, json_body['displayName'])
     self.assertEqual('beer', json_body['beverages'][0])