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")
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)
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())
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")
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])