Skip to content
Snippets Groups Projects
Select Git revision
  • 8057af27dcaf9bb6f42f4566e7b43eff78c72bbe
  • 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_ccaosdb.cpp

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    test_scalars_cfood.py 1.92 KiB
    #!/bin/python
    # Tests for:
    # https://gitlab.com/caosdb/caosdb-crawler/-/issues/9
    # A. Schlemmer, 06/2021
    
    import pytest
    
    # The main function that is affected by this issue:
    from caoscrawler.converters import handle_value
    from caoscrawler.crawl import Crawler
    # We need the store for the above function
    from caoscrawler.stores import GeneralStore
    
    from test_tool import dircheckstr, rfp
    
    
    @pytest.fixture
    def crawler():
        crawler = Crawler(debug=True)
        crawler.crawl_directory(rfp("test_directories", "examples_article"),
                                rfp("cfoods_scalar.yml"))
        return crawler
    
    
    def test_handle_value():
        # Note that we will need this store only, if we also want to test variables substitution:
        store = GeneralStore()
    
        # This one should work:
        assert handle_value("bla", store) == ("bla", "single")
    
        # These failed:
        assert handle_value(4, store) == (4, "single")
        assert handle_value(4.2, store) == (4.2, "single")
        assert handle_value(True, store) == (True, "single")
    
        # List test:
        assert handle_value([4, 3, 2], store) == ([4, 3, 2], "single")
    
    
    def test_record_structure_generation(crawler):
        subd = crawler.debug_tree[dircheckstr("DataAnalysis")]
        assert len(subd) == 2
        # variables store on Data Analysis node of debug tree
        if "Data" in subd[0]:
            subddata = subd[0]
            subdRTGPL = subd[1]
        else:
            subddata = subd[1]
            subdRTGPL = subd[0]
        assert len(subddata) == 5
        assert "DataAnalysis" in subddata
        assert "DataAnalysis.path" in subddata
        assert "Data.path" in subddata
        assert "RecordThatGetsParentsLater" in subddata
    
        prop = subddata["RecordThatGetsParentsLater"].get_property("someId")
        assert type(prop.value) == int
        assert prop.value == 23
    
        # record store on Data Analysis node of debug tree
        assert len(subdRTGPL) == 1
        prop2 = subdRTGPL["RecordThatGetsParentsLater"].get_property("someId")
        assert prop == prop2