Skip to content
Snippets Groups Projects
Select Git revision
  • 19405f4628521fb3a14e40e49718f22199c487e6
  • main default protected
  • f-prefill
  • dev
  • f-docs-pylib
  • f-parse-value
  • f-compare
  • f-string-ids
  • f-217-set-special-property
  • f-filesystem-import
  • f-filesystem-link
  • f-filesystem-directory
  • f-filesystem-core
  • f-filesystem-cleanup
  • f-check-merge-entities
  • f-compare-enid
  • f-select-subproperties
  • v0.18.0
  • v0.17.0
  • v0.16.0
  • v0.15.1
  • v0.15.0
  • v0.14.0
  • v0.13.2
  • v0.13.1
  • v0.13.0
  • linkahead-rename-step-2
  • linkahead-rename-step-1
  • v0.12.0
  • v0.11.2
  • v0.11.1
  • v0.11.0
  • v0.10.0
  • v0.9.0
  • v0.8.0
  • v0.7.4
  • v0.7.3
37 results

test_issues.py

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"