Exemplo n.º 1
0
 def test_class_to_prefix(self):
     self.assertEqual("grant",
                      HashIdentifierStrategy._class_to_prefix(VIVO.Grant))
     self.assertEqual(
         "ro_0000052",
         HashIdentifierStrategy._class_to_prefix(OBO.RO_0000052))
     self.assertIsNone(HashIdentifierStrategy._class_to_prefix(None))
Exemplo n.º 2
0
def default_execute(
    orcid_id,
    namespace=None,
    person_uri=None,
    person_id=None,
    skip_person=False,
    person_class=None,
    confirmed_orcid_id=False,
):
    # Set namespace
    set_namespace(namespace)

    this_identifier_strategy = HashIdentifierStrategy()
    this_person_uri = (
        URIRef(person_uri)
        if person_uri
        else this_identifier_strategy.to_uri(FOAF.Person, {"id": person_id or orcid_id})
    )

    # this_create_strategy will implement both create strategy and identifier strategy
    this_create_strategy = SimpleCreateEntitiesStrategy(
        this_identifier_strategy, skip_person=skip_person, person_uri=this_person_uri
    )

    crosswalker = PersonCrosswalk(create_strategy=this_create_strategy, identifier_strategy=this_create_strategy)
    return crosswalker.crosswalk(
        orcid_id, this_person_uri, person_class=person_class, confirmed_orcid_id=confirmed_orcid_id
    )
Exemplo n.º 3
0
class TestHashIdentifierStrategy(TestCase):
    def setUp(self):
        self.strategy = HashIdentifierStrategy()

    def test_to_identifier(self):
        uri = "http://vivo.mydomain.edu/individual/grant-3c73b079585811b9cbb23c3253a0796a"
        self.assertEqual(uri, str(self.strategy.to_uri(VIVO.Grant, {"foo": "My Foo", "bar": "My Bar"})))
        #Switch order
        self.assertEqual(uri, str(self.strategy.to_uri(VIVO.Grant, {"bar": "My Bar", "foo": "My Foo"})))
        #Add a none
        self.assertEqual(uri, str(self.strategy.to_uri(VIVO.Grant,
                                                              {"foo": "My Foo", "bar": "My Bar", "foobar": None})))
        #General class trumps class
        self.assertEqual(uri, str(self.strategy.to_uri(VIVO.AnotherClazz,
                                                       {"foo": "My Foo", "bar": "My Bar", "foobar": None},
                                                       general_clazz=VIVO.Grant)))

        #Different class
        self.assertNotEqual(uri, str(self.strategy.to_uri(VIVO.NotAGrant, {"foo": "My Foo", "bar": "My Bar"})))
        #General class
        self.assertNotEqual(uri, str(self.strategy.to_uri(VIVO.Grant, {"foo": "My Foo", "bar": "My Bar"},
                                                          general_clazz=VIVO.AnotherClass)))
        #Changed attr
        self.assertNotEqual(uri, str(self.strategy.to_uri(VIVO.Grant, {"foo": "Not My Foo", "bar": "My Bar"})))
        #Additional attr
        self.assertNotEqual(uri, str(self.strategy.to_uri(VIVO.Grant,
                                                                 {"foo": "My Foo", "bar": "My Bar",
                                                                  "foobar": "My FooBar"})))

    def test_class_to_prefix(self):
        self.assertEqual("grant", HashIdentifierStrategy._class_to_prefix(VIVO.Grant))
        self.assertEqual("ro_0000052", HashIdentifierStrategy._class_to_prefix(OBO.RO_0000052))
        self.assertIsNone(HashIdentifierStrategy._class_to_prefix(None))
Exemplo n.º 4
0
def default_execute(orcid_id, namespace=None, person_uri=None, person_id=None, skip_person=False, person_class=None,
                    confirmed_orcid_id=False):
    # Set namespace
    set_namespace(namespace)

    this_identifier_strategy = HashIdentifierStrategy()
    this_person_uri = URIRef(person_uri) if person_uri \
        else this_identifier_strategy.to_uri(FOAF.Person, {"id": person_id or orcid_id})

    # this_create_strategy will implement both create strategy and identifier strategy
    this_create_strategy = SimpleCreateEntitiesStrategy(this_identifier_strategy, skip_person=skip_person,
                                                        person_uri=this_person_uri)

    crosswalker = PersonCrosswalk(create_strategy=this_create_strategy, identifier_strategy=this_create_strategy)
    return crosswalker.crosswalk(orcid_id, this_person_uri, person_class=person_class,
                                 confirmed_orcid_id=confirmed_orcid_id)
Exemplo n.º 5
0
 def setUp(self):
     self.graph = Graph(namespace_manager=ns.ns_manager)
     self.person_uri = ns.D["test"]
     self.create_strategy = SimpleCreateEntitiesStrategy(
         HashIdentifierStrategy(), person_uri=self.person_uri)
     self.crosswalker = FundingCrosswalk(
         identifier_strategy=self.create_strategy,
         create_strategy=self.create_strategy)
Exemplo n.º 6
0
 def setUp(self):
     self.strategy = HashIdentifierStrategy()
Exemplo n.º 7
0
class TestHashIdentifierStrategy(TestCase):
    def setUp(self):
        self.strategy = HashIdentifierStrategy()

    def test_to_identifier(self):
        uri = "http://vivo.mydomain.edu/individual/grant-3c73b079585811b9cbb23c3253a0796a"
        self.assertEqual(
            uri,
            str(
                self.strategy.to_uri(VIVO.Grant, {
                    "foo": "My Foo",
                    "bar": "My Bar"
                })))
        #Switch order
        self.assertEqual(
            uri,
            str(
                self.strategy.to_uri(VIVO.Grant, {
                    "bar": "My Bar",
                    "foo": "My Foo"
                })))
        #Add a none
        self.assertEqual(
            uri,
            str(
                self.strategy.to_uri(VIVO.Grant, {
                    "foo": "My Foo",
                    "bar": "My Bar",
                    "foobar": None
                })))
        #General class trumps class
        self.assertEqual(
            uri,
            str(
                self.strategy.to_uri(VIVO.AnotherClazz, {
                    "foo": "My Foo",
                    "bar": "My Bar",
                    "foobar": None
                },
                                     general_clazz=VIVO.Grant)))

        #Different class
        self.assertNotEqual(
            uri,
            str(
                self.strategy.to_uri(VIVO.NotAGrant, {
                    "foo": "My Foo",
                    "bar": "My Bar"
                })))
        #General class
        self.assertNotEqual(
            uri,
            str(
                self.strategy.to_uri(VIVO.Grant, {
                    "foo": "My Foo",
                    "bar": "My Bar"
                },
                                     general_clazz=VIVO.AnotherClass)))
        #Changed attr
        self.assertNotEqual(
            uri,
            str(
                self.strategy.to_uri(VIVO.Grant, {
                    "foo": "Not My Foo",
                    "bar": "My Bar"
                })))
        #Additional attr
        self.assertNotEqual(
            uri,
            str(
                self.strategy.to_uri(VIVO.Grant, {
                    "foo": "My Foo",
                    "bar": "My Bar",
                    "foobar": "My FooBar"
                })))

    def test_class_to_prefix(self):
        self.assertEqual("grant",
                         HashIdentifierStrategy._class_to_prefix(VIVO.Grant))
        self.assertEqual(
            "ro_0000052",
            HashIdentifierStrategy._class_to_prefix(OBO.RO_0000052))
        self.assertIsNone(HashIdentifierStrategy._class_to_prefix(None))
Exemplo n.º 8
0
 def setUp(self):
     self.strategy = HashIdentifierStrategy()
Exemplo n.º 9
0
 def test_class_to_prefix(self):
     self.assertEqual("grant", HashIdentifierStrategy._class_to_prefix(VIVO.Grant))
     self.assertEqual("ro_0000052", HashIdentifierStrategy._class_to_prefix(OBO.RO_0000052))
     self.assertIsNone(HashIdentifierStrategy._class_to_prefix(None))