Skip to content
Snippets Groups Projects
Select Git revision
  • 1804063f2111626d99cd5529dde62d3ab17721f8
  • main default protected
  • dev protected
  • f-fix-accent-sensitivity
  • f-filesystem-import
  • f-update-acl
  • f-filesystem-link
  • f-filesystem-directory
  • f-filesystem-core
  • f-filesystem-cleanup
  • f-string-ids
  • f-filesystem-main
  • f-multipart-encoding
  • f-trigger-advanced-user-tools
  • f-real-rename-test-pylibsolo2
  • f-real-rename-test-pylibsolo
  • f-real-rename-test
  • f-linkahead-rename
  • f-reference-record
  • f-xml-serialization
  • f-xfail-server-181
  • linkahead-pylib-v0.18.0
  • linkahead-control-v0.16.0
  • linkahead-pylib-v0.17.0
  • linkahead-mariadbbackend-v8.0.0
  • linkahead-server-v0.13.0
  • caosdb-pylib-v0.15.0
  • caosdb-pylib-v0.14.0
  • caosdb-pylib-v0.13.2
  • caosdb-server-v0.12.1
  • caosdb-pylib-v0.13.1
  • caosdb-pylib-v0.12.0
  • caosdb-server-v0.10.0
  • caosdb-pylib-v0.11.1
  • caosdb-pylib-v0.11.0
  • caosdb-server-v0.9.0
  • caosdb-pylib-v0.10.0
  • caosdb-server-v0.8.1
  • caosdb-pylib-v0.8.0
  • caosdb-server-v0.8.0
  • caosdb-pylib-v0.7.2
41 results

test_tickets_200.py

Blame
    • Timm Fitschen's avatar
      1804063f
      TST: server side scripting · 1804063f
      Timm Fitschen authored
      Squashed commit of the following:
      
      commit feea533048a28badbdc09be9dfcf6faf7a00c394
      Author: Timm Fitschen <t.fitschen@indiscale.com>
      Date:   Tue Sep 3 10:28:20 2019 +0200
      
          TST: skip empty text value (until fixed)
      
      commit 9ece19b1d30547bf62e48d79a21e1a148ff48ece
      Merge: 6290274 1c81f890
      Author: Timm Fitschen <t.fitschen@indiscale.com>
      Date:   Tue Sep 3 09:30:21 2019 +0200
      
          Merge branch 'dev' into f-server-side-scripting
      
      commit 6290274d119a284b0cf957daa7755a4d01e4bdbd
      Merge: 6c40bb1 fc5977f6
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Wed Aug 28 15:21:08 2019 +0200
      
          Merge branch 'dev' into f-server-side-scripting
      
      commit fc5977f6
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Wed Aug 28 15:10:40 2019 +0200
      
          DEV: added test for usage of empty strings
      
      commit 6c40bb1f78df44af855f93d29495e4b139a4948b
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Sat Aug 17 15:44:35 2019 +0200
      
          cosmetcis
      
      commit 5daf49823ff4dd2273df786e6f88c38575a81b26
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Fri Aug 16 21:49:44 2019 +0200
      
          MAINT: remove depricated assert_equals
      
      commit e8ca7fc0849fbc4fff43abbb22a340e78ca04c32
      Merge: 483b08a 5789272a
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Fri Aug 16 21:48:59 2019 +0200
      
          Merge branch 'dev' into f-server-side-scripting
      
      commit 483b08a11e72cd5d0c1039f7ca425c4824b946c5
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Thu Aug 15 17:58:09 2019 +0200
      
          FIX: removed assertion that was uncomplete
      
      commit dafc7886cc15110ca28c626d32be27204d106fe3
      Merge: 2e732d6 e1971635
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Thu Aug 15 14:10:52 2019 +0200
      
          Merge branch 'dev' into f-server-side-scripting
      
      commit 2e732d63bc71f61edcbb7e31169b3ec9217583d5
      Merge: ac9af7e 7b876f97
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Thu Aug 15 14:06:17 2019 +0200
      
          Merge branch 'dev' into f-server-side-scripting
      
      commit ac9af7e3883770602c305e09ea543d00aa7fb170
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Thu Mar 28 10:24:52 2019 +0100
      
          TST: fix tests for mariadb
      
      commit 156b77d7b925fc4e225de9dfcb4224f4b7dc4540
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Wed Mar 27 15:13:10 2019 +0100
      
          TST: add another test for like queries
      
      commit 156a8a717c0c42a7534a86de2c7843aa50e8aab0
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Wed Mar 27 11:09:50 2019 +0100
      
          TST: test like queries
      
      commit dcd2181155b256b7800aa312d6f38e726f1ef17b
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Fri Mar 22 14:53:23 2019 +0100
      
          TEST: add tests for CHECK_ENTITY_ACL_ROLES_MODE
      
      commit ac56d505385690da962efe9d40df2c71c4d42f55
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Tue Dec 18 22:50:11 2018 +0100
      
          TST: changes due to changed std. config of server
      
      commit 994201dab6e483c05bed8500806585c0e8f42590
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Tue Dec 11 23:34:13 2018 +0100
      
          TST: Test AccessControl Bug
      
      commit fa3426cae23939ab7c8a370b5230910331b89ddc
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Mon Dec 10 16:09:10 2018 +0100
      
          TST: fix configuration without password_method
      
      commit c353ea395aa4737290605e42a24ae6983e7edb76
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Wed Dec 5 01:45:04 2018 +0100
      
          TST: make tests compatible with password_method = pass
      
      commit f09809f47587d50ec8c4e68da5db526d14aa2222
      Merge: d66940c 44390a1c
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Wed Dec 5 00:56:14 2018 +0100
      
          Merge branch 'dev' into f-server-side-scripting
      
      commit d66940cf4ead03ae7f64fba66adde26f24722ab6
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Wed Dec 5 00:36:28 2018 +0100
      
          TST: fix test_benchmark for userInfo
      
      commit 6da4a48878cc55a8c0527d91286340dd561ab5e7
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Tue Dec 4 23:40:02 2018 +0100
      
          TST: fix test_query for userInfo
      
      commit 157b90571485fec89b4de3900aef32c4c79d9dad
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Tue Dec 4 16:30:23 2018 +0100
      
          TST: fix test_files for userInfo
      
      commit 909f1cd4010a528934bb41baa978b035288cf5e6
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Tue Nov 20 00:03:39 2018 +0100
      
          TST: reset password method for dummy user
      
      commit 6b904b83b44a40f7d3dd0a7646f1eb5c662b2164
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Mon Nov 19 21:44:21 2018 +0100
      
          update tests for mysql 5.7
      
      commit 6dd4c04482000de60439fd9e56ad5dd67f907257
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Wed Oct 17 13:51:58 2018 +0200
      
          TST: added setup for installing test scripts
      
      commit b090913f630d4f8c304bf9b71196f0e9c2ae102c
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Tue Oct 16 00:06:20 2018 +0200
      
          TST: update tox.ini
      
      commit 661a915a617033afdb105257911c9a4082daa6ce
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Mon Oct 15 23:51:14 2018 +0200
      
          TST: pytest instead of py.test
      
      commit 7129bce97f1c5e2145465396c944a7b71b13bc70
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Mon Oct 15 23:39:59 2018 +0200
      
          BUG: added encoding to test_server_side_scripting
      
      commit b1289861a2b5c92d2e0ac0d5b3eed4ea3b899dfe
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Mon Oct 15 21:04:28 2018 +0200
      
          TST: skip test which needs a script to be installed
      
      commit 1bc9aa1979cb9e7ebeaf5648ad5a87231dd2bd1e
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Mon Oct 15 20:48:34 2018 +0200
      
          DOC: Added license header
      
      commit f7407d725cab7c2b632797d30c1985ac73749153
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Mon Oct 15 20:44:10 2018 +0200
      
          TST: Test for server-side scripting
      Verified
      1804063f
      History
      TST: server side scripting
      Timm Fitschen authored
      Squashed commit of the following:
      
      commit feea533048a28badbdc09be9dfcf6faf7a00c394
      Author: Timm Fitschen <t.fitschen@indiscale.com>
      Date:   Tue Sep 3 10:28:20 2019 +0200
      
          TST: skip empty text value (until fixed)
      
      commit 9ece19b1d30547bf62e48d79a21e1a148ff48ece
      Merge: 6290274 1c81f890
      Author: Timm Fitschen <t.fitschen@indiscale.com>
      Date:   Tue Sep 3 09:30:21 2019 +0200
      
          Merge branch 'dev' into f-server-side-scripting
      
      commit 6290274d119a284b0cf957daa7755a4d01e4bdbd
      Merge: 6c40bb1 fc5977f6
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Wed Aug 28 15:21:08 2019 +0200
      
          Merge branch 'dev' into f-server-side-scripting
      
      commit fc5977f6
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Wed Aug 28 15:10:40 2019 +0200
      
          DEV: added test for usage of empty strings
      
      commit 6c40bb1f78df44af855f93d29495e4b139a4948b
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Sat Aug 17 15:44:35 2019 +0200
      
          cosmetcis
      
      commit 5daf49823ff4dd2273df786e6f88c38575a81b26
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Fri Aug 16 21:49:44 2019 +0200
      
          MAINT: remove depricated assert_equals
      
      commit e8ca7fc0849fbc4fff43abbb22a340e78ca04c32
      Merge: 483b08a 5789272a
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Fri Aug 16 21:48:59 2019 +0200
      
          Merge branch 'dev' into f-server-side-scripting
      
      commit 483b08a11e72cd5d0c1039f7ca425c4824b946c5
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Thu Aug 15 17:58:09 2019 +0200
      
          FIX: removed assertion that was uncomplete
      
      commit dafc7886cc15110ca28c626d32be27204d106fe3
      Merge: 2e732d6 e1971635
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Thu Aug 15 14:10:52 2019 +0200
      
          Merge branch 'dev' into f-server-side-scripting
      
      commit 2e732d63bc71f61edcbb7e31169b3ec9217583d5
      Merge: ac9af7e 7b876f97
      Author: Henrik tom Wörden <henrik@trineo.org>
      Date:   Thu Aug 15 14:06:17 2019 +0200
      
          Merge branch 'dev' into f-server-side-scripting
      
      commit ac9af7e3883770602c305e09ea543d00aa7fb170
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Thu Mar 28 10:24:52 2019 +0100
      
          TST: fix tests for mariadb
      
      commit 156b77d7b925fc4e225de9dfcb4224f4b7dc4540
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Wed Mar 27 15:13:10 2019 +0100
      
          TST: add another test for like queries
      
      commit 156a8a717c0c42a7534a86de2c7843aa50e8aab0
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Wed Mar 27 11:09:50 2019 +0100
      
          TST: test like queries
      
      commit dcd2181155b256b7800aa312d6f38e726f1ef17b
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Fri Mar 22 14:53:23 2019 +0100
      
          TEST: add tests for CHECK_ENTITY_ACL_ROLES_MODE
      
      commit ac56d505385690da962efe9d40df2c71c4d42f55
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Tue Dec 18 22:50:11 2018 +0100
      
          TST: changes due to changed std. config of server
      
      commit 994201dab6e483c05bed8500806585c0e8f42590
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Tue Dec 11 23:34:13 2018 +0100
      
          TST: Test AccessControl Bug
      
      commit fa3426cae23939ab7c8a370b5230910331b89ddc
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Mon Dec 10 16:09:10 2018 +0100
      
          TST: fix configuration without password_method
      
      commit c353ea395aa4737290605e42a24ae6983e7edb76
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Wed Dec 5 01:45:04 2018 +0100
      
          TST: make tests compatible with password_method = pass
      
      commit f09809f47587d50ec8c4e68da5db526d14aa2222
      Merge: d66940c 44390a1c
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Wed Dec 5 00:56:14 2018 +0100
      
          Merge branch 'dev' into f-server-side-scripting
      
      commit d66940cf4ead03ae7f64fba66adde26f24722ab6
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Wed Dec 5 00:36:28 2018 +0100
      
          TST: fix test_benchmark for userInfo
      
      commit 6da4a48878cc55a8c0527d91286340dd561ab5e7
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Tue Dec 4 23:40:02 2018 +0100
      
          TST: fix test_query for userInfo
      
      commit 157b90571485fec89b4de3900aef32c4c79d9dad
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Tue Dec 4 16:30:23 2018 +0100
      
          TST: fix test_files for userInfo
      
      commit 909f1cd4010a528934bb41baa978b035288cf5e6
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Tue Nov 20 00:03:39 2018 +0100
      
          TST: reset password method for dummy user
      
      commit 6b904b83b44a40f7d3dd0a7646f1eb5c662b2164
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Mon Nov 19 21:44:21 2018 +0100
      
          update tests for mysql 5.7
      
      commit 6dd4c04482000de60439fd9e56ad5dd67f907257
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Wed Oct 17 13:51:58 2018 +0200
      
          TST: added setup for installing test scripts
      
      commit b090913f630d4f8c304bf9b71196f0e9c2ae102c
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Tue Oct 16 00:06:20 2018 +0200
      
          TST: update tox.ini
      
      commit 661a915a617033afdb105257911c9a4082daa6ce
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Mon Oct 15 23:51:14 2018 +0200
      
          TST: pytest instead of py.test
      
      commit 7129bce97f1c5e2145465396c944a7b71b13bc70
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Mon Oct 15 23:39:59 2018 +0200
      
          BUG: added encoding to test_server_side_scripting
      
      commit b1289861a2b5c92d2e0ac0d5b3eed4ea3b899dfe
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Mon Oct 15 21:04:28 2018 +0200
      
          TST: skip test which needs a script to be installed
      
      commit 1bc9aa1979cb9e7ebeaf5648ad5a87231dd2bd1e
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Mon Oct 15 20:48:34 2018 +0200
      
          DOC: Added license header
      
      commit f7407d725cab7c2b632797d30c1985ac73749153
      Author: Timm Fitschen <timm.fitschen@ds.mpg.de>
      Date:   Mon Oct 15 20:44:10 2018 +0200
      
          TST: Test for server-side scripting
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    test_error_stuff.py 10.23 KiB
    # encoding: utf-8
    #
    # ** header v3.0
    # This file is a part of the CaosDB Project.
    #
    # Copyright (C) 2018 Research Group Biomedical Physics,
    # Max-Planck-Institute for Dynamics and Self-Organization Göttingen
    # Copyright (C) 2020 Indiscale GmbH <info@indiscale.com>
    # Copyright (C) 2020 Florian Spreckelsen <f.spreckelsen@indiscale.com>
    #
    # This program is free software: you can redistribute it and/or modify
    # it under the terms of the GNU Affero General Public License as
    # published by the Free Software Foundation, either version 3 of the
    # License, or (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU Affero General Public License for more details.
    #
    # You should have received a copy of the GNU Affero General Public License
    # along with this program. If not, see <https://www.gnu.org/licenses/>.
    #
    # ** end header
    #
    """Test different entity errors.
    
    Created on 19.02.2015.
    
    @author: tf
    
    """
    import caosdb as h
    from caosdb.exceptions import (EntityDoesNotExistError, EntityError,
                                   EntityHasNoDatatypeError,
                                   TransactionError, UniqueNamesError,
                                   UnqualifiedParentsError,
                                   UnqualifiedPropertiesError)
    import pytest
    
    
    def setup_module():
        try:
            h.execute_query("FIND Test*").delete()
        except:
            pass
    
    
    def setup():
        """No additional setup required."""
        setup_module()
    
    
    def teardown():
        """Delete everything."""
        setup_module()
    
    
    def test_retrieval_no_exception_raised():
        """Test whether retrieval fails but error is suppressed."""
        p = h.Property(name="TestNon-ExsistentProperty").retrieve(
            unique=True, raise_exception_on_error=False)
        assert not p.is_valid()
        assert (p.id is None or p.id < 0)
    
    
    def test_retrieval_exception_raised():
        """Test if a TransactionError with the correct child is raised, and if
        the child has the correct super classes.
    
        """
        propname = "TestNon-ExistentProperty"
        with pytest.raises(TransactionError) as te:
            h.Property(name="TestNon-ExistentProperty").retrieve(unique=True,
                                                                 raise_exception_on_error=True)
        assert len(te.value.get_errors()) == 1
        ee = te.value.get_errors()[0]
        # Check for type incl. inheritance
        assert isinstance(ee, EntityDoesNotExistError)
        assert isinstance(ee, EntityError)
        assert isinstance(ee, TransactionError)
        # Correct entity causing the error:
        assert not (ee.get_entity() is None)
        assert ee.get_entity().name == propname
        assert not ee.get_entity().is_valid()
        assert ee.get_entity().has_errors()
    
    
    def test_insertion_no_exception_raised():
        """Test whether insertion fails but no error is raised."""
        p = h.Property(name="TestNoTypeProperty").insert(
            raise_exception_on_error=False)
        assert not p.is_valid()
        assert (p.id is None or p.id < 0)
    
    
    def test_insertion_exception_raised():
        """Test insertion of a property with missing datatype."""
        p = h.Property(name="TestNoTypeProperty")
        with pytest.raises(TransactionError) as te:
            p.insert(raise_exception_on_error=True)
        assert te.value.has_error(EntityHasNoDatatypeError)
    
    
    def test_insertion_with_invalid_parents():
        with pytest.raises(TransactionError) as te:
            p = h.Property(
                name="TestNoTypeProperty",
                datatype="Text").add_parent(
                id=-1)
            p.insert(raise_exception_on_error=True)
        upe = te.value.get_errors()[0]
        print(upe)
        assert isinstance(upe, UnqualifiedParentsError)
        assert not upe.get_entity() is None
        assert upe.get_entity().name == p.name
        assert upe.get_entity().id == p.id
        assert upe.get_entity().has_errors()
        assert not p.is_valid()
        assert not upe.get_entity().is_valid()
        assert not upe.get_entities() is None
    
    
    def test_insertion_with_invalid_properties():
        with pytest.raises(TransactionError) as te:
            p = h.Property(
                name="TestNoTypeProperty",
                datatype="Text").add_property(
                id=-1)
            p.insert(raise_exception_on_error=True)
        upe = te.value.get_errors()[0]
        assert isinstance(upe, UnqualifiedPropertiesError)
        assert not upe.get_entity() is None
        assert upe.get_entity().name == p.name
        assert upe.get_entity().has_errors()
        assert p.has_errors()
        assert not p.is_valid()
        assert not upe.get_entity().is_valid()
    
    
    def test_entity_does_not_exist():
        """When retrieving a container with existing and non-existing
        entities, only those that don't exist should cause
        EntityDoesNotExistErrors.
    
        """
        p1 = h.Property(name="TestNon-ExistentProperty1").retrieve(
            raise_exception_on_error=False)
        p2 = h.Property(name="TestNon-ExistentProperty2").retrieve(
            raise_exception_on_error=False)
        p3 = h.Property(name="TestNon-ExistentProperty3").retrieve(
            raise_exception_on_error=False)
        # None of them should exist
        assert not p1.is_valid()
        assert (p1.id is None or p1.id < 0)
        assert not p2.is_valid()
        assert (p2.id is None or p2.id < 0)
        assert not p3.is_valid()
        assert (p3.id is None or p3.id < 0)
    
        pe = h.Property(name="TestExistentProperty", datatype="text").insert()
    
        c = h.Container().extend(
            [
                h.Property(
                    name="TestNon-ExistentProperty1"),
                h.Property(
                    name="TestNon-ExistentProperty2"),
                h.Property(
                    name="TestNon-ExistentProperty3"),
                h.Property(
                    name="TestExistentProperty")])
    
        with pytest.raises(TransactionError) as te:
            c.retrieve()
        te = te.value
        assert te.has_error(EntityDoesNotExistError)
        # Only non-existing entities caused the container error
        assert not pe.name in [x.name for x in te.get_all_entities()]
        for p in (p1, p2, p3):
            assert p.name in [x.name for x in te.get_all_entities()]
    
    
    def test_insert_existent_entity():
        """Insertion of an already existing entity should cause a
        UniqueNamesError.
    
        """
        p1 = h.Property(name="TestNon-ExistentProperty1").retrieve(
            raise_exception_on_error=False)
        p2 = h.Property(name="TestNon-ExistentProperty2").retrieve(
            raise_exception_on_error=False)
        p3 = h.Property(name="TestNon-ExistentProperty3").retrieve(
            raise_exception_on_error=False)
        # None of them should exist
        assert not p1.is_valid()
        assert (p1.id is None or p1.id < 0)
        assert not p2.is_valid()
        assert (p2.id is None or p2.id < 0)
        assert not p3.is_valid()
        assert (p3.id is None or p3.id < 0)
    
        pe = h.Property(name="TestExistentProperty", datatype="text").insert()
        assert pe.is_valid()
    
        c = h.Container().extend(
            [
                h.Property(
                    name="TestNon-ExistentProperty1",
                    datatype="text"),
                h.Property(
                    name="TestNon-ExistentProperty2",
                    datatype="text"),
                h.Property(
                    name="TestNon-ExistentProperty3",
                    datatype="text"),
                h.Property(
                    name="TestExistentProperty",
                    datatype="text")])
    
        with pytest.raises(TransactionError) as te:
            c.insert(unique=True)
        te = te.value
        assert te.has_error(UniqueNamesError)
        une = te.get_errors()[0]
        assert not une.get_entity() is None
        assert pe.name == une.get_entity().name
        for p in (p1, p2, p3):
            assert not p in te.get_all_entities()
    
    
    def test_double_insertion():
        c1 = h.Container()
    
        c1.append(
            h.Property(
                name="TestSimpleTextProperty",
                description="simple text property (from test_error_stuff.py)",
                datatype='text'))
        c1.append(
            h.Property(
                name="TestSimpleDoubleProperty",
                description="simple double property (from test_error_stuff.py)",
                datatype='double'))
        c1.append(
            h.Property(
                name="TestSimpleIntegerProperty",
                description="simple integer property (from test_error_stuff.py)",
                datatype='integer'))
        c1.append(
            h.Property(
                name="TestSimpleDatetimeProperty",
                description="simple datetime property (from test_error_stuff.py)",
                datatype='datetime'))
    
        c1.append(
            h.RecordType(
                name="TestSimpleRecordType",
                description="simple recordType (from test_error_stuff.py)").add_property(
                    name='TestSimpleTextProperty').add_property(
                        name='TestSimpleDoubleProperty').add_property(
                            name='TestSimpleIntegerProperty').add_property(
                                name='TestSimpleDatetimeProperty'))
    
        c1.insert()
    
        c2 = h.Container()
        c2.append(
            h.Property(
                name="TestSimpleTextProperty",
                description="simple text property (from test_error_stuff.py)",
                datatype='text'))
        c2.append(
            h.Property(
                name="TestSimpleDoubleProperty",
                description="simple double property (from test_error_stuff.py)",
                datatype='double'))
        c2.append(
            h.Property(
                name="TestSimpleIntegerProperty",
                description="simple integer property (from test_error_stuff.py)",
                datatype='integer'))
        c2.append(
            h.Property(
                name="TestSimpleDatetimeProperty",
                description="simple datetime property (from test_error_stuff.py)",
                datatype='datetime'))
    
        c2.append(
            h.RecordType(
                name="TestSimpleRecordType",
                description="simple recordType (from test_error_stuff.py)").add_property(
                    name='TestSimpleTextProperty').add_property(
                        name='TestSimpleDoubleProperty').add_property(
                            name='TestSimpleIntegerProperty').add_property(
                                name='TestSimpleDatetimeProperty'))
        with pytest.raises(TransactionError) as te:
            c2.insert()
        te = te.value
        assert te.has_error(UniqueNamesError)
        # c2 caused the ContainerError
        assert te.get_container() == c2
        # exactly 5 faulty entities in c2
        assert len(te.get_entities()) == 5