def test_customer_delete_invalid_uuid(self, service_admin): """Try to delete customer with invalid uuid""" # All requests will throw an exception if response is an error code try: service_admin.delete_customer(uuid.uuid1()) raise KokuException("Customer deleted with invalid uuid") except HTTPError: pass
def test_customer_create_no_owner(self, service_admin): uniq_string = fauxfactory.gen_string('alphanumeric', 8) name = 'Customer {}'.format(uniq_string) try: service_admin.create_customer(name=name, owner=None) raise KokuException("Customer created with no owner") except HTTPError: pass
def test_user_preference_get_invalid_preference_uuid(self, new_user): new_user.login() try: new_user.read_preference(uuid.uuid1()) raise KokuException( "User preference was retrieved with invalid preference") except HTTPError: pass
def test_user_preference_delete_invalid_uuid(self, new_user): new_user.login() try: new_user.delete_preference(uuid.uuid1()) raise KokuException( "User preference with an invalid uuid was deleted") except HTTPError: pass
def test_user_get_invalid_uuid(self, new_customer): """Try to get user with invalid uuid""" # All requests will throw an exception if response is an error code try: new_customer.read_user(uuid.uuid1()) raise KokuException( "User retrieval was successful with an invalid uuid") except HTTPError: pass
def test_user_preference_create_no_name(self, new_user): new_user.login() try: new_user.create_preference( name=None, preference={'currency': 'USD'}, description='Negative Preference Description') raise KokuException("User preference was created with no name") except HTTPError: pass
def test_user_create_no_email(self, new_customer): """Try to create a new user without email""" # All requests will throw an exception if response is an error code uniq_string = fauxfactory.gen_string('alphanumeric', 8) try: new_customer.create_user(username='******'.format(uniq_string), email='', password='******') raise KokuException("User was created with no email") except HTTPError: pass
def test_customer_create_owner_invalid_email(self, service_admin): uniq_string = fauxfactory.gen_string('alphanumeric', 8) name = 'Customer {}'.format(uniq_string) owner = { 'username': '******'.format(uniq_string), 'email': 'user_{0}{0}.com'.format(uniq_string), 'password': '******', } try: service_admin.create_customer(name=name, owner=owner) raise KokuException("Customer created with invalid owner email") except HTTPError: pass
def reload(self): """Send a GET request based on the current uuid to reload the current member data""" if not self.uuid: raise KokuException( 'Unable to refresh {} object. No uuid specified'.format(self.__class__)) response = self.read() response_data = response.json() self_vars = self.payload() for key in response_data: if key in self_vars: setattr(self, key, response_data[key])
def test_user_preference_create_invalid_preference(self, new_user, pref_name, pref_value): new_user.login() try: new_user.create_preference( name=pref_name, preference={pref_name: pref_value}, description='Invalid {} value: {}'.format( pref_name, pref_value)) raise KokuException( "{} user preference was created with an invalid value: {}". format(pref_name, pref_value)) except HTTPError: pass
def test_user_preference_create_duplicate(self, new_user): new_user.login() preference_list = new_user.list_preferences() orig_preference = preference_list.pop() try: new_user.create_preference( name=orig_preference['name'], preference=orig_preference['preference'], description=orig_preference['description']) raise KokuException( 'Duplicate user preference was created successfully') except HTTPError: pass
def test_user_preference_update_invalid_preference_uuid(self, new_user): new_user.login() new_user.create_preference( name='editor', preference={'editor': 'vim'}, description='Negative Preference Description') pref_uuid = new_user.last_response.json()['uuid'] try: new_user.update_preference( uuid.uuid1(), name='editor', preference={'editor': 'vim'}, description='Negative Preference Description') raise KokuException("User preference was created with no name") except HTTPError: pass
def test_user_preference_update_valid_uuid_invalid_data(self, new_user): new_user.login() try: preference_list = new_user.list_preferences() # This should fail so grab the first preference uuid in the list pref_uuid = preference_list[0]['uuid'] new_user.update_preference( pref_uuid, name='fake_pref', preference={'fake_pref': 'XXX'}, description= 'Invalid preference name allowed for valid preference uuid') raise KokuException( 'Invalid preference name allowed for valid preference uuid') except HTTPError: pass
def test_user_preference_update_invalid_data(self, new_user, pref_name, pref_value): new_user.login() try: preference_list = new_user.list_preferences() # This should fail so grab the first preference uuid in the list pref_uuid = next((pref['uuid'] for pref in preference_list if pref_name in pref['preference'].keys())) new_user.update_preference( pref_uuid, name=pref_name, preference={pref_name: pref_value}, description='Invalid {} value: {}'.format( pref_name, pref_value)) raise KokuException( "{} user preference was updated with an invalid value: {}". format(pref_name, pref_value)) except HTTPError: pass