diff --git a/tests/test_error_stuff.py b/tests/test_error_stuff.py index 296f58d07b196616167101a30b8bcef712b713e9..b970a117302f1f93f1586ae6c48f1268bc786679 100644 --- a/tests/test_error_stuff.py +++ b/tests/test_error_stuff.py @@ -73,8 +73,8 @@ def test_retrieval_exception_raised(): """ propname = "TestNon-ExistentProperty" with pytest.raises(TransactionError) as te: - h.Property(name="Non-ExistentProperty").retrieve(unique=True, - raise_exception_on_error=True) + h.Property(name="TestNon-ExistentProperty").retrieve(unique=True, + raise_exception_on_error=True) # retrieve returns a container, so treat that one separately ce = te.value.get_errors()[0] assert isinstance(ce, ContainerError) @@ -87,8 +87,6 @@ def test_retrieval_exception_raised(): # Correct entity causing the error: assert not (ee.get_entity() is None) assert ee.get_entity().name == propname - assert len(ee.get_entities()) == 1 - assert ee.get_entities()[0].name == propname def test_insertion_no_exception_raised(): @@ -125,7 +123,7 @@ def test_insertion_with_invalid_parents(): assert upe.get_entity().has_errors() assert not p.is_valid() assert not upe.get_entity().is_valid() - assert nt upe.get_entities() is not None + assert not upe.get_entities() is None def test_insertion_with_invalid_properties(): @@ -144,7 +142,7 @@ def test_insertion_with_invalid_properties(): assert upe.get_entity().has_errors() assert p.has_errors() assert not p.is_valid() - assert not e.get_entity().is_valid() + assert not upe.get_entity().is_valid() def test_entity_does_not_exist(): @@ -184,9 +182,12 @@ def test_entity_does_not_exist(): c.retrieve() te = te.value assert te.has_error(EntityDoesNotExistError) - assert not pe in te.get_all_entities() + # Only non-existing entities caused the container error + assert not pe.name in [x.name for x in + te.get_errors()[0].get_all_entities()] for p in (p1, p2, p3): - assert p in te.get_all_entities() + assert p.name in [x.name for x in + te.get_errors()[0].get_all_entities()] def test_insert_existent_entity(): @@ -226,12 +227,11 @@ def test_insert_existent_entity(): name="TestExistentProperty", datatype="text")]) - with pytest.raises(TransActionError) as te: + with pytest.raises(TransactionError) as te: c.insert(unique=True) te = te.value assert te.has_error(UniqueNamesError) une = te.get_errors()[0].get_errors()[0] - assert len(une.get_entities) == 1 assert not une.get_entity() is None assert pe.name == une.get_entity().name for p in (p1, p2, p3): @@ -303,7 +303,7 @@ def test_double_insertion(): name='TestSimpleDoubleProperty').add_property( name='TestSimpleIntegerProperty').add_property( name='TestSimpleDatetimeProperty')) - with pytest.raises(TransActionError) as te: + with pytest.raises(TransactionError) as te: c2.insert() te = te.value assert te.has_error(UniqueNamesError)