Example #1
0
    def setUpClass(cls):

        check_spec_test_env()
        # import the results file
        results_file = os.path.join(_TEST_DIR, 'djornl', 'results.json')
        with open(results_file) as fh:
            cls.json_data = json.load(fh)

        cls.no_results = {'nodes': [], 'edges': []}
        cls.maxDiff = None

        # load the DB
        root_path = os.path.join(_TEST_DIR, 'djornl', 'test_data')
        with modified_environ(RES_ROOT_DATA_PATH=root_path):
            parser = DJORNL_Parser()
            node_name = parser.config('node_name')
            edge_name = parser.config('edge_name')

            edge_data = parser.load_edges()
            r = create_test_docs(node_name, edge_data['nodes'])
            print_db_update(r, node_name)
            r = create_test_docs(edge_name, edge_data['edges'])
            print_db_update(r, edge_name)

            node_metadata = parser.load_nodes()
            r = create_test_docs(node_name, node_metadata['nodes'], True)
            print_db_update(r, node_name)

            cluster_data = parser.load_clusters()
            r = create_test_docs(node_name, cluster_data['nodes'], True)
            print_db_update(r, node_name)
Example #2
0
 def setUpClass(cls):
     check_spec_test_env()
Example #3
0
    def setUpClass(cls):
        """Create test documents"""

        check_spec_test_env()

        taxon_docs = [
            {'_key': '1', 'scientific_name': 'Bacteria', 'rank': 'Domain', 'strain': False},
            {'_key': '2', 'scientific_name': 'Firmicutes', 'rank': 'Phylum', 'strain': False},
            {'_key': '3', 'scientific_name': 'Bacilli', 'rank': 'Class', 'strain': False},
            {'_key': '4', 'scientific_name': 'Proteobacteria', 'rank': 'Phylum', 'strain': False},
            {'_key': '5', 'scientific_name': 'Alphaproteobacteria', 'rank': 'Class', 'strain': False},
            {'_key': '6', 'scientific_name': 'Gammaproteobacteria', 'rank': 'Class', 'strain': False},
            {'_key': '7', 'scientific_name': 'Deltaproteobacteria', 'rank': 'Class', 'strain': False},
            {'_key': '8', 'scientific_name': 'Bacillus subtilis 168', 'rank': 'no rank', 'strain': True},
        ]
        child_docs = [
            {'_from': 'ncbi_taxon/2', '_to': 'ncbi_taxon/1', 'from': '2', 'to': '1', 'id': '2'},
            {'_from': 'ncbi_taxon/4', '_to': 'ncbi_taxon/1', 'from': '4', 'to': '1', 'id': '4'},
            {'_from': 'ncbi_taxon/3', '_to': 'ncbi_taxon/2', 'from': '3', 'to': '2', 'id': '3'},
            {'_from': 'ncbi_taxon/5', '_to': 'ncbi_taxon/4', 'from': '5', 'to': '4', 'id': '5'},
            {'_from': 'ncbi_taxon/6', '_to': 'ncbi_taxon/4', 'from': '6', 'to': '4', 'id': '6'},
            {'_from': 'ncbi_taxon/7', '_to': 'ncbi_taxon/4', 'from': '7', 'to': '4', 'id': '7'},
            # a few levels missing here
            {'_from': 'ncbi_taxon/8', '_to': 'ncbi_taxon/3', 'from': '8', 'to': '3', 'id': '8'},
        ]
        obj_ver_docs = [
            _construct_ws_obj_ver(1, 1, 1, is_public=True),
            _construct_ws_obj_ver(1, 1, 2, is_public=True),
            _construct_ws_obj_ver(2, 1, 1, is_public=False),
        ]
        obj_docs = [
            _construct_ws_obj(1, 1, is_public=True),
            _construct_ws_obj(2, 1, is_public=False),
        ]
        obj_to_taxa_docs = [
            {'_from': 'ws_object_version/1:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn1'},
            {'_from': 'ws_object_version/1:1:2', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'},
            {'_from': 'ws_object_version/2:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'},
        ]
        # Create workspace objects associated to taxa
        ws_docs = [
            _ws_defaults({'_key': '1', 'is_public': True}),
            _ws_defaults({'_key': '2', 'is_public': False}),
        ]
        ws_to_obj = [
            {'_from': 'ws_workspace/1', '_to': 'ws_object/1:1'},
            {'_from': 'ws_workspace/2', '_to': 'ws_object/2:1'},
        ]
        ws_type_version_docs = [
            {'_key': 'KBaseGenomes.Genome-99.77', 'module_name': 'KBaseGenomes',
             'type_name': 'Genome', 'maj_ver': 99, 'min_ver': 77}
        ]
        ws_obj_instance_of_type_docs = [
            {'_from': 'ws_object_version/1:1:1', '_to': 'ws_type_version/KBaseGenomes.Genome-99.77'},
            {'_from': 'ws_object_version/1:1:2', '_to': 'ws_type_version/KBaseGenomes.Genome-99.77'}
        ]
        _create_delta_test_docs('ncbi_taxon', taxon_docs)
        _create_delta_test_docs('ncbi_child_of_taxon', child_docs, edge=True)
        create_test_docs('ws_obj_version_has_taxon', obj_to_taxa_docs)
        create_test_docs('ws_object', obj_docs)
        create_test_docs('ws_workspace', ws_docs)
        create_test_docs('ws_workspace_contains_obj', ws_to_obj)
        create_test_docs('ws_object_version', obj_ver_docs)
        create_test_docs('ws_obj_instance_of_type', ws_obj_instance_of_type_docs)
        create_test_docs('ws_type_version', ws_type_version_docs)
Example #4
0
    def setUpClass(cls):
        """
        Create all test data.
        """

        check_spec_test_env()

        ws_object_version = [
            _ws_obj(1, 1, 1),  # root/origin object
            _ws_obj(1, 2, 1),  # copy object
            _ws_obj(1, 3, 1),  # provenance object
            _ws_obj(1, 4, 1),  # reference object
            _ws_obj(1, 5, 1, is_public=False),  # private copy obj
            _ws_obj(1, 6, 1, is_public=False),  # private prov obj
            _ws_obj(1, 7, 1, is_public=False),  # private ref obj
        ]
        create_test_docs('ws_object_version', ws_object_version)
        ws_type_version = [{'_key': 'Module.Type1-1.0'}]
        create_test_docs('ws_type_version', ws_type_version)
        ws_obj_instance_of_type = [
            {
                '_from': 'ws_object_version/1:1:1',
                '_to': 'ws_type_version/Module.Type1-1.0'
            },
            {
                '_from': 'ws_object_version/1:2:1',
                '_to': 'ws_type_version/Module.Type1-1.0'
            },
            {
                '_from': 'ws_object_version/1:3:1',
                '_to': 'ws_type_version/Module.Type1-1.0'
            },
            {
                '_from': 'ws_object_version/1:4:1',
                '_to': 'ws_type_version/Module.Type1-1.0'
            },
        ]
        create_test_docs('ws_obj_instance_of_type', ws_obj_instance_of_type)
        ws_prov_descendant_of = [
            {
                '_from': 'ws_object_version/1:1:1',
                '_to': 'ws_object_version/1:3:1'
            },
            {
                '_from': 'ws_object_version/1:1:1',
                '_to': 'ws_object_version/1:6:1'
            },
        ]
        create_test_docs('ws_prov_descendant_of', ws_prov_descendant_of)
        ws_refers_to = [
            {
                '_from': 'ws_object_version/1:1:1',
                '_to': 'ws_object_version/1:4:1'
            },
            {
                '_from': 'ws_object_version/1:1:1',
                '_to': 'ws_object_version/1:7:1'
            },
        ]
        create_test_docs('ws_refers_to', ws_refers_to)
        ws_copied_from = [
            {
                '_from': 'ws_object_version/1:1:1',
                '_to': 'ws_object_version/1:2:1'
            },
            {
                '_from': 'ws_object_version/1:1:1',
                '_to': 'ws_object_version/1:5:1'
            },
        ]
        create_test_docs('ws_copied_from', ws_copied_from)