def test_basic_update(self, test_data): """ @feature: Permissions @test: try to update entity first with relevant permissionn @assert: entity is removed """ entity = test_data() created = ApiCrud.record_create_recursive(entity) created = test_data._meta.change_for_update(created) user_definition = User() user_created = ApiCrud.record_create_recursive(user_definition) # user doesn't yet have relevant permission, action should fail with self.assertRaises(Exception): ApiCrud.record_update(created, user_definition) perm = ApiCrud.record_resolve( test_data._meta.api_class.permissions.update ) add_permission_to_user(user_created, perm) # user should have the relevant permission, action should updated = ApiCrud.record_update(created, user_definition) del created["updated_at"] del updated["updated_at"] self.assertIntersects(created, updated)
def test_basic_update(self, test_data): """ @feature: Permissions @test: try to update entity first with relevant permissionn @assert: entity is removed """ entity = test_data() created = ApiCrud.record_create_recursive(entity) created = test_data._meta.change_for_update(created) user_definition = User() user_created = ApiCrud.record_create_recursive(user_definition) # user doesn't yet have relevant permission, action should fail with self.assertRaises(Exception): ApiCrud.record_update(created, user_definition) perm = ApiCrud.record_resolve( test_data._meta.api_class.permissions.update) add_permission_to_user(user_created, perm) # user should have the relevant permission, action should updated = ApiCrud.record_update(created, user_definition) del created["updated_at"] del updated["updated_at"] self.assertIntersects(created, updated)
def add_permission_to_user(user_created, perm): role = Role() created_role = ApiCrud.record_create(role) flter = Filter() flter.role_id = created_role.id flter.permission_ids = [perm.id] ApiCrud.record_create(flter) user_created.role_ids = [created_role.id] ApiCrud.record_update(user_created)
def add_permission_to_user(user_created, perm): role = Role() created_role = ApiCrud.record_create(role) flter = Filter() flter.role_id = created_role.id flter.permission_ids = [perm.id] ApiCrud.record_create(flter) user_created.role_ids = [created_role.id] ApiCrud.record_update(user_created)
def test_positive_update_1(self, test_data): """ @feature: Organizations @test: Create organization with valid values then update its name @assert: organization name is updated """ org = Organization() org = ApiCrud.record_create(org) org.name = test_data.name ApiCrud.record_update(org)
def test_positive_update_1(self, test_data): """ @feature: Organizations @test: Create organization with valid values then update its name @assert: organization name is updated """ org = Organization() org = ApiCrud.record_create(org) org.name = test_data.name ApiCrud.record_update(org)
def test_positive_update_2(self, test_data): """ @feature: Organizations @test: Create organization with valid values then update its label @assert: organization label is updated """ org = Organization() org = ApiCrud.record_create(org) org.label = test_data.label ApiCrud.record_update(org)
def test_positive_update_3(self, test_data): """ @feature: Organizations @test: Create organization with valid values then update its description @assert: organization description is updated """ org = Organization() org = ApiCrud.record_create(org) org.description = test_data.description ApiCrud.record_update(org)
def test_positive_update_3(self, test_data): """ @feature: Organizations @test: Create organization with valid values then update its description @assert: organization description is updated """ org = Organization() org = ApiCrud.record_create(org) org.description = test_data.description ApiCrud.record_update(org)
def test_positive_update_4(self, test_data): """ @feature: Organizations @test: Create organization with valid values then update all values @assert: organization name, label and description are updated """ org = Organization() org = ApiCrud.record_create(org) org.name = test_data.name org.description = test_data.description ApiCrud.record_update(org)
def test_cv_edit(self, data): """ @test: edit content views - name, description, etc. @feature: Content Views @assert: edited content view save is successful and info is updated """ con_view = ContentViewDefinition() depends = ApiCrud.record_create_dependencies(con_view) t = ApiCrud.record_create(depends) con_view.name = data.name ApiCrud.record_update(t)
def test_negative_update_2(self, test_data): """ @feature: Organizations @test: Create organization with valid values then fail to update its label @assert: organization label is not updated """ org = Organization() org = ApiCrud.record_create(org) org.label = test_data.label correctly_failing = True try: ApiCrud.record_update(org) correctly_failing = False except ApiException: correctly_failing = correctly_failing and True self.assertTrue(correctly_failing)
def test_remove_user_3(self, test_data): """ @feature: Organizations @test: Create admin users then add user and remove it by using the organization name @assert: The user is added then removed from the organization @status: manual """ u = ApiCrud.record_create_recursive(test_data) self.assertTrue("organizations" in u) u.organization_ids = [] ur = ApiCrud.record_update(u) self.assertFalse("organizations" in ur)
def test_update(self, test_data): """ @feature: ActivationKey @test: Verify, that update funkcionality works as intended @assert: different description is created after update. """ update_desc = test_data.description test_data.description = "empty" ak_cr = ApiCrud.record_create(test_data) self.assertIntersects(ak_cr, test_data) ak_cr.description = update_desc ak_u = ApiCrud.record_update(ak_cr) self.assertEquals(ak_u.description, ak_cr.description)
def test_remove_user_3(self, test_data): """ @feature: Organizations @test: Create admin users then add user and remove it by using the organization name @assert: The user is added then removed from the organization @status: manual """ u = ApiCrud.record_create_recursive(test_data) self.assertTrue("organizations" in u) u.organization_ids = [] ur = ApiCrud.record_update(u) self.assertFalse("organizations" in ur)
def test_update(self, test_data): """ @feature: CustomProduct @test: Verify, that update funkcionality works as intended @assert: different description is created after update. """ update_desc = test_data.description test_data.description = "empty" ak_cr = ApiCrud.record_create_recursive(test_data) self.assertIntersects(ak_cr, test_data) ak_cr.description = update_desc ak_u = ApiCrud.record_update(ak_cr) self.assertEquals(ak_u.description, ak_cr.description)
def test_update(self, ak): """ @feature: ActivationKey @test: Verify, that update funkcionality works as intended @assert: different description is created after update. """ update_desc = ak.description ak.description = "empty" ak_cr = ApiCrud.record_create(ak) self.assertIntersects(ak_cr, ak) ak_cr.description = update_desc ak_u = ApiCrud.record_update(ak_cr) self.assertEquals(ak_u.description, ak_cr.description)
def test_remove_user_1(self, test_data): """ @feature: Organizations @test: Create different types of users then add/remove user by using the organization ID @assert: User is added and then removed from organization @status: manual """ u = ApiCrud.record_create_recursive(test_data) self.assertTrue("organizations" in u) u.organization_ids = [] ur = ApiCrud.record_update(u) self.assertFalse("organizations" in ur)
def test_remove_user_1(self, test_data): """ @feature: Organizations @test: Create different types of users then add/remove user by using the organization ID @assert: User is added and then removed from organization @status: manual """ u = ApiCrud.record_create_recursive(test_data) self.assertTrue("organizations" in u) u.organization_ids = [] ur = ApiCrud.record_update(u) self.assertFalse("organizations" in ur)