Skip to content
Snippets Groups Projects
Select Git revision
  • 3bb354503454493a178e7d23bcaeffb2a81a7cb9
  • main default protected
  • f-yaml-parser-enums
  • dev protected
  • f-fix-paths
  • f-fix-validate-to-dict
  • f-labfolder-converter
  • f-state-machine-script
  • f-xlsx-converter-warnings-errors
  • f-rename
  • f-extra-deps
  • f-more-jsonschema-export
  • f-henrik
  • f-fix-89
  • f-trigger-advanced-user-tools
  • f-real-rename-test
  • f-linkahead-rename
  • f-register-integrationtests
  • f-fix-id
  • f-h5-files
  • f-json-schema
  • v0.14.0
  • v0.13.0
  • v0.12.0
  • v0.11.0
  • v0.10.0-numpy2
  • v0.10.0
  • v0.9.0
  • v0.8.0
  • v0.7.0
  • v0.6.1
  • v0.6.0
  • v0.5.0
  • v0.4.1
  • v0.4.0
  • v0.3.1
  • v0.3.0
37 results

test_im_und_export.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    test_im_und_export.py 1.51 KiB
    #!/usr/bin/env python3
    import os
    import unittest
    from tempfile import TemporaryDirectory
    
    import caosdb as db
    
    from caosadvancedtools.export_related import export
    from caosadvancedtools.import_from_xml import import_xml
    
    if __name__ == "__main__":
        print("Conducting im- and export tests")
        rec = db.execute_query("FIND 2019-02-03_really_cool_finding", unique=True)
        directory = TemporaryDirectory()
        export(rec.id, directory=directory.name)
        # delete everything
        rec = db.execute_query("FIND record which was inserted by me")
        prop = db.execute_query("FIND property which was inserted by me")
        rt = db.execute_query("FIND recordtype which was inserted by me")
        fi = db.execute_query("FIND file which was inserted by me")
        c = db.Container()
        c.extend(rec+prop+rt+fi)
        c.delete()
        assert 0 == len(db.execute_query("FIND File which is stored at "
                                         "**/poster.pdf"))
        import_xml(os.path.join(directory.name, "caosdb_data.xml"), interactive=False)
    
        # The following tests the existence of some required entities.
        # However, this is not a full list.
        db.execute_query("FIND 2019-02-03_really_cool_finding", unique=True)
        db.execute_query("FIND RecordType Poster", unique=True)
        db.execute_query("FIND RecordType Analysis", unique=True)
        db.execute_query("FIND RecordType Person", unique=True)
        db.execute_query("FIND Record Person with firstname=Only", unique=True)
        db.execute_query("FIND File which is stored at **/poster.pdf", unique=True)