예제 #1
0
 def _wrap_with_entity(self, search_result):
     identifier = Entity.extract_id_from_url(search_result.self_link,
                                             self.path)
     return self.constructor(
         identifier, search_result.data["source"], self.path) if type(
             search_result.data
         ) is dict and "source" in search_result.data else None
예제 #2
0
 def test_extract_id_from_url_with_wrong_entity(self):
     with self.assertRaises(ValueError):
         Entity.extract_id_from_url(
             "http://kg:8080/v0/organizations/hbp/core/celloptimization/v0.0.1",
             Schema.path)
예제 #3
0
 def test_extract_id_from_url_with_slash_at_the_end(self):
     result = Entity.extract_id_from_url(
         "http://kg:8080/v0/schemas/hbp/core/celloptimization/v0.0.1/",
         Schema.path)
     self.assertEqual(result, "hbp/core/celloptimization/v0.0.1")
예제 #4
0
 def test_extract_id_from_url_with_anchor(self):
     result = Entity.extract_id_from_url(
         "http://kg:8080/v0/schemas/hbp/core/celloptimization/v0.0.1#hello_world",
         Schema.path)
     self.assertEqual(result, "hbp/core/celloptimization/v0.0.1")
예제 #5
0
 def test_extract_id_from_url_with_param(self):
     result = Entity.extract_id_from_url(
         "http://kg:8080/v0/schemas/hbp/core/celloptimization/v0.0.1?hello_world", Schema.path)
     assert result == "hbp/core/celloptimization/v0.0.1"
예제 #6
0
 def resolve(self, search_result):
     identifier = Entity.extract_id_from_url(search_result.self_link,
                                             self.path)
     data = self._read(identifier)
     return Context(identifier, data,
                    self.path) if data is not None else None
예제 #7
0
 def test_extract_id_from_url(self):
     result = Entity.extract_id_from_url("http://kg:8080/v0/schemas/hbp/core/celloptimization/v0.0.1", Schema.path)
     assert_that(result, equal_to("hbp/core/celloptimization/v0.0.1"))