Skip to content
Snippets Groups Projects
Select Git revision
  • e54b19a1ff10441d92d29bb87586cc3bede43df8
  • main default protected
  • f-sss4grpc
  • dev
  • 108-implement-rpc-call-for-server-side-scripting
  • f-windows-conan-create
  • f-to-string
  • f-update-requirements
  • f-related-projects
  • f-role
  • f-remote-path
  • f-rel-path
  • f-consol-message
  • v0.3.0
  • v0.2.2
  • v0.2.1
  • v0.2.0
  • v0.1.2
  • v0.1.1
  • v0.1
  • v0.0.19
  • v0.0.18
  • v0.0.16
  • v0.0.15
  • v0.0.10
  • v0.0.9
  • v0.0.8
  • v0.0.7
  • v0.0.6
  • v0.0.5
  • v0.0.4
  • v0.0.3
  • v0.0.2
33 results

test_issues.cpp

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    test_issues.py 2.12 KiB
    # This file is a part of the LinkAhead Project.
    #
    # Copyright (c) 2022 IndiScale GmbH
    # Copyright (c) 2022 Daniel Hornung (d.hornung@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/>.
    
    """Test known issues to prevent regressions.
    """
    
    import os
    
    import lxml
    import linkahead as db
    
    from pytest import raises
    
    
    def test_issue_100():
        """_parse_value() fails for some list-valued content
        """
    
        # Parse from (invalid) XML file
        filename = os.path.join(os.path.dirname(__file__), "data", "list_in_value.xml")
        xml_el = lxml.etree.parse(filename).getroot()
        with raises(TypeError) as exc_info:
            db.common.models._parse_single_xml_element(xml_el)
        assert "Invalid datatype: List valued properties" in str(exc_info.value)
    
    
    def test_issue_156():
        """Does parse_value make a mistake with entities?
    
        https://gitlab.indiscale.com/caosdb/src/caosdb-pylib/-/issues/156
        """
        project = db.Record(name="foo")
        project.add_parent(name="RTName")
        # <Record name="foo">
        #   <Parent name="RTName"/>
        # </Record>
        experiment = db.Record()
        experiment.add_property(name="RTName", value=project)
        # <Record>
        #   <Property name="RTName" importance="FIX" flag="inheritance:FIX">foo</Property>
        # </Record>
        value = experiment.get_property("RTName").value
        # <Record name="foo">
        #   <Parent name="RTName"/>
        # </Record>
        parents = value.get_parents()
        # <ParentList>
        #   <Parent name="RTName"/>
        # </ParentList>
        assert value is project
        assert parents[0].name == "RTName"