provdbconnector.tests package

Submodules

provdbconnector.tests.examples module

provdbconnector.tests.examples.prov_db_unknown_prov_typ_example()[source]
provdbconnector.tests.examples.prov_default_namespace_example(ns_postfix: str)[source]
provdbconnector.tests.examples.attributes_dict_example()[source]

Retuns a example dict with some different attributes

Returns:dict with attributes
Return type:dict
provdbconnector.tests.examples.base_connector_bundle_parameter_example()[source]

This example returns a dict with example arguments for a db_adapter

Returns:dict {attributes, metadata}
Return type:dict
provdbconnector.tests.examples.base_connector_record_parameter_example()[source]

Returns a dict with attributes and metadata for a simple node

:return:dict with attributes metadata :rtype: dict

provdbconnector.tests.examples.base_connector_relation_parameter_example()[source]

Returns a example with a start nodes (attributes, metadata) and also a relation dict with attributes metadata

Returns:dict
Return type:dict
provdbconnector.tests.examples.base_connector_merge_example()[source]

This example returns a namedtuple with a from_node relation and to_node to test the merge behavior

Returns:namedtuple(from_node, relation, to_node)
Return type:namedtuple
provdbconnector.tests.examples.prov_api_record_example()[source]

This is a more complex record example

Returns:

provdbconnector.tests.test_prov_db module

class provdbconnector.tests.test_prov_db.ProvDbTestTemplate(*args, **kwargs)[source]

Bases: unittest.case.TestCase

This abstract test class to test the high level function of you database adapter. To use this unitest Template extend from this class.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
        """
        auth_info = {"invalid": "Invalid"}
        with self.assertRaises(InvalidOptionsException):
            self.instance.connect(auth_info)

    def clear_database(self):
        """
        Clear the database

        """
        self.instance.all_nodes = dict()
        self.instance.all_relations= dict()

    def tearDown(self):
        """
        Delete your instance
setUp()[source]

Use the setup method to create a provapi instance with you adapter

Warning

Override this function if you extend this test! Otherwise the test will fail.

Returns:
clear_database()[source]

Override this function to clear your database before each test

Returns:
test_prov_primer_example()[source]

This test try to save and restore a common prov example document

Returns:
test_primer_example_alternate()[source]

This test try to save and restore a common prov example document. But in a more complex way

Returns:
test_w3c_publication_1()[source]

This test try to save and restore a common prov example document.

Returns:
test_w3c_publication_2()[source]

This test try to save and restore a common prov example document.

Returns:
test_bundles1()[source]

This test try to save and restore a common prov example document. With a bundle and some connections inside the bundle. This example is also available via Provstore <https://provenance.ecs.soton.ac.uk/store/documents/114710/>

Returns:
test_bundles2()[source]

This test try to save and restore a common prov example document. With a bundle and some connections inside the bundle. This example is also available via Provstore <https://provenance.ecs.soton.ac.uk/store/documents/114704/>

The main difference to the bundle_1 is that here we have also a mentionOf connection between bundles. See PROV-Links spec for more information

Returns:
test_collections()[source]

This test try to save and restore a common prov example document.

Returns:
test_long_literals()[source]

This test try to save and restore a common prov example document.

Returns:
test_datatypes()[source]

This test try to save and restore a common prov example document.

Returns:
class provdbconnector.tests.test_prov_db.ProvDbTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

This tests are only for the ProvDb itself. You don’t have to extend this test in case you want to write your own adapter

maxDiff = None
setUp()[source]

Loads the test xml json and provn data

clear_database()[source]
tearDown()[source]

Destroy the prov api and remove all data from neo4j :return:

test_provapi_instance()[source]

Try to create a test instnace :return:

test_save_document_from_json()[source]

Try to create a document from a json buffer :return:

test_get_document_as_json()[source]

try to get the document as json :return:

test_save_document_from_xml()[source]

Try to create a document from xml :return:

test_get_document_as_xml()[source]

try to get the document as xml :return:

test_save_document_from_provn()[source]

Try to create a document from provn :return:

test_get_document_as_provn()[source]

Try to get a document in provn :return:

test_save_document()[source]

Try to create a document from a prov instnace :return:

test_save_document_from_prov()[source]

Try to create a primer example document :return:

test_save_document_from_prov_alternate()[source]

Try to create a prov_alternative :return:

test_save_document_from_prov_bundles()[source]

Try to create a document with bundles :return:

test_save_document_from_prov_bundles2()[source]

Try to create more bundles :return:

test_save_document_from_prov_invalid_arguments()[source]

Try to create a prov with some invalid arguments :return:

test_get_document_as_prov()[source]

Try to get the document as ProvDocument instnace

Returns:
test_get_document_as_prov_invalid_arguments()[source]

Try to get the prov document with invalid arguments

Returns:
test_save_bundle_invalid_arguments()[source]

Try to create a bundle with invalid arguments :return:

test_save_element_invalid()[source]

Test save_element with invalid args

test_save_record()[source]

Test to save a record (a element or a relation)

test_save_record_invalid()[source]
test_save_element()[source]

Try to save a single record without document_di

test_get_elements()[source]

Test for the get_elements function

test_get_element_invalid()[source]

Test get element with error

test_get_element()[source]

Try to save a single record without document_id and get the record back from the db

test_save_bundle()[source]

Test the public method to save bundles

test_save_bundle_invalid()[source]

Test the public method to save bundles with invalid arguments

test_get_bundle()[source]

Test the public method to get bundles

test_get_bundle_invalid()[source]

Test with invalid arguemnts

test_save_relation_with_unknown_nodes()[source]

Test to create a relation were the start and end node dose not exist This should also work

test_save_relation_invalid()[source]
test_get_metadata_and_attributes_for_record_invalid_arguments()[source]

Try to get attributes and metadata with invalid arguments :return:

test_save_unknown_prov_typ()[source]

Test to prefer non unknown prov type

test_save_with_override_default_namespace()[source]

Test to support default namespace overrides

test_get_metadata_and_attributes_for_record()[source]

Test the split into metadata / attributes function This function separates the attributes and metadata from a prov record :return:

Module contents

provdbconnector.tests.additional_tests()[source]