diff --git a/tests/test_permissions.py b/tests/test_permissions.py index 11cd7986846bbccfb31be0f60e90dc0d7c276af8..b036f92eb9bc5b316247d12655d2e27e7fae8cf8 100644 --- a/tests/test_permissions.py +++ b/tests/test_permissions.py @@ -253,37 +253,32 @@ def test_query(): # this fails if server is configured with # QUERY_FILTER_ENTITIES_WITHOUT_RETRIEVE_PERMISSIONS = FALSE - with assert_raises(db.TransactionError) as cm: + with raises(db.TransactionError) as cm: db.execute_query( "FIND TestExperiment WHICH HAS A TestConductor WHICH has a TestFirstName=Daniel", unique=True) - assert_equal(cm.exception.msg, "No such entity found.") + assert cm.value.has_error(db.EntityDoesNotExistError) '''... but works without the which clause''' - assert_equal( - db.execute_query( - "FIND TestExperiment", - unique=True).id, - exp.id) + assert db.execute_query("FIND TestExperiment", unique=True).id == exp.id '''and with the id''' - assert_equal( - db.execute_query( - "FIND TestExperiment WHICH HAS A TestConductor=" + str(dan.id), - unique=True).id, exp.id) + assert db.execute_query( + "FIND TestExperiment WHICH HAS A TestConductor=" + str(dan.id), + unique=True).id == exp.id '''failure - exp''' grant_permission(dan, "RETRIEVE:*") deny_permission(exp, "RETRIEVE:*") switch_to_test_user() - with assert_raises(db.TransactionError) as cm: + with raises(db.TransactionError) as cm: db.execute_query( "FIND TestExperiment WHICH HAS A TestConductor=TestDaniel", unique=True) - assert_equal(cm.exception.msg, "No such entity found.") + assert cm.value.has_error(db.EntityDoesNotExistError) - with assert_raises(db.TransactionError) as cm: + with raises(db.TransactionError) as cm: db.execute_query("FIND TestExperiment", unique=True) - assert_equal(cm.exception.msg, "No such entity found.") + assert cm.value.has_error(db.EntityDoesNotExistError) @with_setup(setup, teardown) @@ -362,37 +357,30 @@ def test_update_acl(): p3.acl.deny( username=db.get_config().get("Connection", "username"), permission="USE:AS_PROPERTY") - try: + with raises(db.TransactionError) as te: p3.update_acl() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) p3 = db.execute_query( "FIND TestProperty", unique=True, flags={ "ACL": None}) - assert_true(p3.is_valid()) - assert_is_not_none(p3.acl) - assert_true( - "USE:AS_PROPERTY" in p3.acl.get_permissions_for_user( - db.get_config().get("Connection", "username"))) - assert_false( - "USE:AS_DATA_TYPE" in p3.acl.get_permissions_for_user( - db.get_config().get("Connection", "username"))) - assert_false( - "EDIT:ACL" in p3.acl.get_permissions_for_user( + assert p3.is_valid() + assert p3.acl is not None + assert ("USE:AS_PROPERTY" in p3.acl.get_permissions_for_user( db.get_config().get("Connection", "username"))) + assert not ("USE:AS_DATA_TYPE" in p3.acl.get_permissions_for_user( + db.get_config().get("Connection", "username"))) + assert not ("EDIT:ACL" in p3.acl.get_permissions_for_user( + db.get_config().get("Connection", "username"))) '''Failure''' switch_to_test_user() p3.acl.grant(username=test_user, permission="EDIT:ACL") - try: + with raises(db.TransactionError) as te: p3.update() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) @with_setup(setup, teardown) @@ -419,15 +407,13 @@ def test_update_name(): assert_false("UPDATE:NAME" in p.permissions) p.name = "TestPropertyEvenNewer" - try: + with raises(db.TransactionError) as te: p.update() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) p2 = db.execute_query("FIND Test*", unique=True) - assert_true(p2.is_valid()) - assert_equal(p2.name, "TestPropertyNew") + assert p2.is_valid() + assert p2.name == "TestPropertyNew" @with_setup(setup, teardown) @@ -455,15 +441,13 @@ def test_update_desc(): '''Failure''' p.description = "DescriptionEvenNewer" - try: + with raises(db.TransactionError) as te: p.update() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) p2 = db.execute_query("FIND Test*", unique=True) - assert_true(p2.is_valid()) - assert_equal(p2.description, "DescriptionNew") + assert p2.is_valid() + assert p2.description == "DescriptionNew" @with_setup(setup, teardown) @@ -487,15 +471,13 @@ def test_update_data_type(): '''Failure''' p.datatype = db.DOUBLE - try: + with raises(db.TransactionError) as te: p.update() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) p2 = db.execute_query("FIND Test*", unique=True) - assert_true(p2.is_valid()) - assert_equal(p2.datatype, db.INTEGER) + assert p2.is_valid() + assert p2.datatype == db.INTEGER @with_setup(setup, teardown) @@ -517,15 +499,13 @@ def test_update_role(): '''Failure''' rec = db.Record(name="TestProperty").retrieve() - try: + with raises(db.TransactionError) as te: rec.update() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) rt2 = db.execute_query("FIND Test*", unique=True) - assert_true(rt2.is_valid()) - assert_true(isinstance(rt2, db.RecordType)) + assert rt2.is_valid() + assert isinstance(rt2, db.RecordType) @with_setup(setup, teardown) @@ -554,14 +534,12 @@ def test_update_move_file(): '''FAILURE''' f.path = "/againotherpermissiontestfiles/test.dat" - try: + with raises(db.TransactionError) as te: f.update() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) f2 = db.execute_query("FIND TestFile", unique=True) - assert_equal(f2.path, "/otherpermissiontestfiles/test.dat") + assert f2.path == "/otherpermissiontestfiles/test.dat" @with_setup(setup, teardown) @@ -571,21 +549,19 @@ def test_update_add_file(): upload_file.close() f = db.File(name="TestFile").insert() - assert_true(f.is_valid()) + assert f.is_valid() grant_permission(f, "RETRIEVE:ENTITY") '''FAILURE''' f.path = "/permissiontestfiles/newtest.dat" f.file = upload_file - try: + with raises(db.TransactionError) as te: f.update() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) f2 = db.execute_query("FIND TestFile", unique=True) - assert_is_none(f2.path) + assert f2.path is None '''SUCCESS''' grant_permission(f, "UPDATE:FILE:ADD") @@ -622,16 +598,14 @@ def test_update_change_file(): deny_permission(f, "UPDATE:FILE:REMOVE") f.file = upload_file2 - try: + with raises(db.TransactionError) as te: f.update() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) f2 = db.execute_query("FIND TestFile", unique=True) download_file = f2.download() - assert_equal(db.File._get_checksum(download_file), - db.File._get_checksum(upload_file)) + assert db.File._get_checksum( + download_file) == db.File._get_checksum(upload_file) '''SUCCESS''' print('#################################################################') @@ -645,12 +619,12 @@ def test_update_change_file(): f2 = db.execute_query("FIND TestFile", unique=True) f2.file = upload_file2 f2.update() - assert_true(f2.is_valid()) + assert f2.is_valid() f2 = db.execute_query("FIND TestFile", unique=True) download_file = f2.download() - assert_equal(db.File._get_checksum(download_file), - db.File._get_checksum(upload_file2)) + assert db.File._get_checksum( + download_file) == db.File._get_checksum(upload_file2) @with_setup(setup, teardown) @@ -684,27 +658,23 @@ def test_update_add_property(): '''Failure - add p to rt''' rt.add_property(name="TestProperty", id=p.id) - try: + with raises(db.TransactionError) as te: rt.update() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) rt2 = db.execute_query("FIND TestRecordType", unique=True) - assert_equal(len(rt2.get_properties()), 1) - assert_is_not_none(rt2.get_property("TestProperty")) + assert len(rt2.get_properties()) == 1 + assert rt2.get_property("TestProperty") is not None '''Failure - add p2 to rt''' rt.add_property(name="TestProperty2", id=p2.id) - try: + with raises(db.TransactionError) as te: rt.update() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) rt2 = db.execute_query("FIND TestRecordType", unique=True) - assert_equal(len(rt2.get_properties()), 1) - assert_is_not_none(rt2.get_property("TestProperty")) + assert len(rt2.get_properties()) == 1 + assert rt2.get_property("TestProperty") is not None @with_setup(setup, teardown) @@ -744,15 +714,13 @@ def test_update_remove_property(): '''Failure - remove p from rt''' rt.remove_property("TestProperty") - try: + with raises(db.TransactionError) as te: rt.update() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) rt2 = db.execute_query("FIND TestRecordType", unique=True) - assert_equal(len(rt2.get_properties()), 1) - assert_is_not_none(rt2.get_property("TestProperty")) + assert len(rt2.get_properties()) == 1 + assert rt2.get_property("TestProperty") is not None @with_setup(setup, teardown) @@ -785,28 +753,24 @@ def test_update_add_parent(): '''Failure - add par1 to rt''' rt.add_parent(name="TestRecordTypePar1", id=par1.id) - try: + with raises(db.TransactionError) as te: rt.update() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) rt2 = db.execute_query("FIND TestRecordType", unique=True) - assert_equal(len(rt2.get_parents()), 1) - assert_is_not_none(rt2.get_parent("TestRecordTypePar1")) + assert len(rt2.get_parents()) == 1 + assert rt2.get_parent("TestRecordTypePar1") is not None '''Failure - add par2 to rt''' rt.add_parent(name="TestRecordTypePar2", id=par2.id) - try: + with raises(db.TransactionError) as te: rt.update() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) rt2 = db.execute_query("FIND TestRecordType", unique=True) - assert_equal(len(rt2.get_parents()), 1) - assert_is_not_none(rt2.get_parent("TestRecordTypePar1")) - assert_is_none(rt2.get_parent("TestRecordTypePar2")) + assert len(rt2.get_parents()) == 1 + assert rt2.get_parent("TestRecordTypePar1") is not None + assert rt2.get_parent("TestRecordTypePar2") is None @with_setup(setup, teardown) @@ -843,16 +807,14 @@ def test_update_remove_parent(): '''Failure''' rt.remove_parent("TestRecordTypePar1") - try: + with raises(db.TransactionError) as te: rt.update() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) rt = db.execute_query("FIND TestRecordType", unique=True) - assert_equal(len(rt.get_parents()), 1) - assert_is_not_none(rt.get_parent("TestRecordTypePar1")) - assert_is_none(rt.get_parent("TestRecordTypePar2")) + assert len(rt.get_parents()) == 1 + assert rt.get_parent("TestRecordTypePar1") is not None + assert rt.get_parent("TestRecordTypePar2") is None @with_setup(setup, teardown) @@ -861,11 +823,11 @@ def test_update_value(): name="TestProperty", datatype=db.TEXT, value="Value").insert() - assert_true(p.is_valid()) + assert p.is_valid() p = db.execute_query("FIND Test*", unique=True) - assert_true(p.is_valid()) - assert_equal(p.value, "Value") + assert p.is_valid() + assert p.value == "Value" grant_permission(p, "RETRIEVE:ENTITY") grant_permission(p, "UPDATE:VALUE") @@ -875,53 +837,48 @@ def test_update_value(): p.update() p = db.execute_query("FIND Test*", unique=True) - assert_true(p.is_valid()) - assert_equal(p.value, "NewValue") + assert p.is_valid() + assert p.value == "NewValue" deny_permission(p, "UPDATE:VALUE") '''Failure''' p.value = "EvenNewerValue" - try: + with raises(db.TransactionError) as te: p.update() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) p2 = db.execute_query("FIND Test*", unique=True) - assert_true(p2.is_valid()) - assert_equal(p2.value, "NewValue") + assert p2.is_valid() + assert p2.value == "NewValue" @with_setup(setup, teardown) def test_deletion(): p = db.Property(name="TestProperty", datatype=db.TEXT).insert() - assert_true(p.is_valid()) + assert p.is_valid() grant_permission(p, "RETRIEVE:ENTITY") '''Failure''' p = db.execute_query("FIND Test*", unique=True) - assert_true(p.is_valid()) - try: + assert p.is_valid() + with raises(db.TransactionError) as te: p.delete() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) '''Success''' grant_permission(p, "DELETE") p.delete() - assert_equal( - p.get_messages()[0].description, - "This entity has been deleted successfully.") + assert p.get_messages()[ + 0].description == "This entity has been deleted successfully." @with_setup(setup, teardown) def test_retrieve_acl(): p = db.Property(name="TestProperty", datatype=db.TEXT).insert() - assert_true(p.is_valid()) + assert p.is_valid() '''Success''' grant_permission(p, "RETRIEVE:*") @@ -930,39 +887,35 @@ def test_retrieve_acl(): '''Failure''' deny_permission(p, "RETRIEVE:ACL") - try: + with raises(db.TransactionError) as te: p.retrieve_acl() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) @with_setup(setup, teardown) def test_retrieve_history(): p = db.Property(name="TestProperty", datatype=db.TEXT).insert() - assert_true(p.is_valid()) + assert p.is_valid() grant_permission(p, "RETRIEVE:ENTITY") '''Failure''' - try: + with raises(db.TransactionError) as te: p.retrieve(flags={"H": None}) - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) '''Success''' grant_permission(p, "RETRIEVE:HISTORY") p.retrieve(flags={"H": None}) - assert_equal(p.messages["History"], ('Insert', None)) + assert p.messages["History"] == ('Insert', None) @with_setup(setup, teardown) def test_retrieve_entity(): p = db.Property(name="TestProperty", datatype=db.TEXT).insert() - assert_true(p.is_valid()) + assert p.is_valid() ''' Success''' grant_permission(p, "RETRIEVE:*") @@ -971,27 +924,23 @@ def test_retrieve_entity(): '''Failure''' deny_permission(p, "RETRIEVE:ENTITY") - try: + with raises(db.TransactionError) as te: p.retrieve() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) @with_setup(setup, teardown) def test_retrieve_owner(): p = db.Property(name="TestProperty", datatype=db.TEXT).insert() - assert_true(p.is_valid()) + assert p.is_valid() '''Failure''' grant_permission(p, "RETRIEVE:ENTITY") deny_permission(p, "RETRIEVE:OWNER") - try: + with raises(db.TransactionError) as te: p.retrieve(flags={"owner": None}) - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, "You are not allowed to do this.") + assert te.value.has_error(db.AuthorizationException) '''Success''' grant_permission(p, "RETRIEVE:OWNER") @@ -1009,7 +958,7 @@ def test_download_file(): name="TestFile", file=upload_file, path="permissiontestfiles/test.dat").insert() - assert_true(f.is_valid()) + assert f.is_valid() '''FAILURE''' f2 = db.execute_query("FIND TestFile", unique=True) @@ -1017,20 +966,16 @@ def test_download_file(): grant_permission(f2, "RETRIEVE:ENTITY") deny_permission(f2, "RETRIEVE:FILE") - try: + with raises(db.HTTPAuthorizationException): f.download() - except db.TransactionError as e: - assert_equal( - e.msg, - "Request failed. The response returned with status 403.") '''SUCCESS''' grant_permission(f2, "RETRIEVE:FILE") f2 = db.execute_query("FIND TestFile", unique=True) download_file = f2.download() - assert_equal(db.File._get_checksum(download_file), - db.File._get_checksum(upload_file)) + assert db.File._get_checksum( + download_file) == db.File._get_checksum(upload_file) @with_setup(setup, teardown) @@ -1038,21 +983,17 @@ def test_grant_priority_permission(): p = db.Property(name="TestProperty2", datatype=db.TEXT).insert() switch_to_test_user() - try: + with raises(db.TransactionError) as te: # other user cannot delete this. p.delete() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, 'You are not allowed to do this.') + assert te.value.has_error(db.AuthorizationException) deny_permission(p, "DELETE") - try: + with raises(db.TransactionError) as te: # still not working p.delete() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, 'You are not allowed to do this.') + assert te.value.has_error(db.AuthorizationException) # now its working grant_permission(p, "DELETE", priority=True) @@ -1064,31 +1005,26 @@ def test_deny_priority_permission(): p = db.Property(name="TestProperty1", datatype=db.TEXT).insert() switch_to_test_user() - try: + with raises(db.TransactionError) as te: # other user cannot delete this. p.delete() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, 'You are not allowed to do this.') + assert te.value.has_error(db.AuthorizationException) deny_permission(p, "DELETE") - try: + with raises(db.TransactionError) as te: # still not working p.delete() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, 'You are not allowed to do this.') + assert te.value.has_error(db.AuthorizationException) - # now its working + # now it's working grant_permission(p, "DELETE") + # now it's not deny_permission(p, "DELETE", priority=True) - try: + with raises(db.TransactionError) as te: # still not working p.delete() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, 'You are not allowed to do this.') + assert te.value.has_error(db.AuthorizationException) @with_setup(setup, teardown) @@ -1103,11 +1039,9 @@ def test_change_priority_permission(): permission="USE:AS_PROPERTY", priority=True) - try: + with raises(db.TransactionError) as te: entity.update_acl() - assert_true(False) - except db.TransactionError as e: - assert_equal(e.msg, 'You are not allowed to do this.') + assert te.value.has_error(db.AuthorizationException) @with_setup(setup, teardown) @@ -1126,7 +1060,8 @@ def test_grant_nonsense_permission(): entity = db.Property(name="TestProperty1", datatype=db.TEXT).insert() entity.retrieve_acl() entity.grant(username="someone", permission="PAINT:BLUE") - assert_raises(db.TransactionError, entity.update_acl) + with raises(db.TransactionError): + entity.update_acl() @with_setup(setup, teardown) @@ -1142,25 +1077,24 @@ def test_global_acl_there(): @with_setup(setup, teardown) def test_use_as_property(): p = db.Property(name="TestProperty", datatype=db.TEXT).insert() - assert_true(p.is_valid()) + assert p.is_valid() switch_to_test_user() rt = db.RecordType(name="TestRecordType").add_property(name="TestProperty") deny_permission(p, "USE:AS_PROPERTY") '''Failure''' deny_permission(p, "USE:AS_PROPERTY") - with assert_raises(db.TransactionError) as cm: + with raises(db.TransactionError) as cm: rt.insert() - ex = cm.exception - assert_equal(ex.msg, "Entity has unqualified properties.") - assert_equal(rt.get_property("TestProperty").get_errors()[0].code, "403") + assert cm.value.has_error(db.UnqualifiedPropertiesError) + assert int(rt.get_property("TestProperty").get_errors()[0].code) == 403 '''Success''' grant_permission(p, "USE:AS_PROPERTY") rt2 = db.RecordType( name="TestRecordType").add_property( name="TestProperty").insert() - assert_true(rt2.is_valid()) + assert rt2.is_valid() @with_setup(setup, teardown) @@ -1174,9 +1108,9 @@ def test_use_as_data_type(): db.Property(name="TestConductorProperty", datatype=dt_name).insert() deny_permission(dt, "USE:AS_DATA_TYPE") - with assert_raises(db.TransactionError) as cm: + with raises(db.TransactionError) as cm: db.Property(name="TestConductorProperty2", datatype=dt_name).insert() - assert_equal(cm.exception.msg, "You are not allowed to do this.") + assert cm.value.has_error(db.AuthorizationException) @with_setup(setup, teardown) @@ -1194,23 +1128,23 @@ def test_use_as_reference(): name="TestRecordType").add_property( name="TestRecordTypeForReference", value=rec).insert() - assert_true(rt.is_valid()) + assert rt.is_valid() deny_permission(rec, "USE:AS_REFERENCE") rt2 = db.RecordType( name="TestRecordType2").add_property( name="TestRecordTypeForReference", value=rec) - with assert_raises(db.TransactionError) as cm: + with raises(db.TransactionError) as cm: rt2.insert() - assert_equal(cm.exception.msg, "Entity has unqualified properties.") - assert_equal(rt2.get_property(p.name).get_errors()[0].code, "403") + assert cm.value.has_error(db.UnqualifiedPropertiesError) + assert int(rt2.get_property(p.name).get_errors()[0].code) == 403 @with_setup(setup, teardown) def test_use_as_parent(): p = db.Property(name="TestProperty", datatype=db.TEXT).insert() - assert_true(p.is_valid()) + assert p.is_valid() switch_to_test_user() p2 = db.Property( @@ -1221,17 +1155,17 @@ def test_use_as_parent(): deny_permission(p, "USE:AS_PARENT") '''Failure''' deny_permission(p, "USE:AS_PARENT") - with assert_raises(db.TransactionError) as cm: + with raises(db.TransactionError) as cm: p2.insert() - assert_equal(cm.exception.msg, "Entity has unqualified parents.") - assert_equal(p2.get_parent("TestProperty").get_errors()[0].code, "403") + assert cm.value.has_error(db.UnqualifiedParentsError) + assert int(p2.get_parent("TestProperty").get_errors()[0].code) == 403 '''Success''' grant_permission(p, "USE:AS_PARENT") p3 = db.Property( name="TestPropertyChild").add_parent( name="TestProperty").insert() - assert_true(p3.is_valid()) + assert p3.is_valid() @with_setup(setup, teardown) @@ -1245,8 +1179,9 @@ def test_access_control_job_bug(): """ revoke_permissions_test_role() switch_to_test_user() - with raises(db.AuthorizationException): + with raises(db.TransactionError) as te: rt1 = db.RecordType(name="TestRT").add_parent(id=-5).insert() + assert te.value.has_error(db.AuthorizationException) set_transaction_permissions_test_role() @@ -1275,7 +1210,7 @@ def test_check_entity_acl_roles(): with raises(db.TransactionError) as cm: grant_permission(p, "USE:AS_PARENT", username="asdf-non-existing", switch=False) - errors = cm.value.entity.get_errors() + errors = cm.value.get_entity().get_errors() assert errors[0].description == "User Role does not exist." db.administration.set_server_property( "CHECK_ENTITY_ACL_ROLES_MODE", "SHOULD")