Esempio n. 1
0
 def test_get_instance_fields_for_property_with_multiple_objects(self):
     query_params = {'expand_uri': u"0"}
     class_schema = {
         "properties": {
             ":hasParent": {
                 "title": "Father or mother"
             },
         }
     }
     elastic_search_item = {
         "fields": {":hasParent": ["Marry", "Harry"]}
     }
     computed = suggest.get_instance_fields(query_params, elastic_search_item, class_schema)
     expected = [
         {
             "predicate_id": ":hasParent",
             "predicate_title": "Father or mother",
             "object_title": "Marry",
             "required": False
         },
         {
             "predicate_id": ":hasParent",
             "predicate_title": "Father or mother",
             "object_title": "Harry",
             "required": False
         }
     ]
     self.assertEqual(computed, expected)
Esempio n. 2
0
 def test_get_instance_fields_for_multiple_fields(self):
     query_params = {'expand_uri': u"0"}
     class_schema = {
         "properties": {
             ":atContry": {"title": "Place is inside country"},
             ":hasMainLanguage": {"title": "Most common language in place"}
         }
     }
     elastic_search_item = {
         "fields": {
             ":atContry": "Peru",
             ":hasMainLanguage": "Spanish"
         }
     }
     computed = suggest.get_instance_fields(query_params, elastic_search_item, class_schema)
     expected = [
         {
             "predicate_id": ":hasMainLanguage",
             "predicate_title": "Most common language in place",
             "object_title": "Spanish",
             "required": False
         },
         {
             "predicate_id": ":atContry",
             "predicate_title": "Place is inside country",
             "object_title": "Peru",
             "required": False
         }
     ]
     self.assertEqual(computed, expected)
Esempio n. 3
0
 def test_get_instance_fields_for_not_required_object_property(self):
     query_params = {'expand_uri': u"0"}
     class_schema = {
         "properties": {
             "http://predicate2": {"title": "predicate2_title"}
         }
     }
     elastic_search_item = {
         "fields": {
             "http://predicate2": {
                 "title": "predicate2_value_label",
                 "@id": "http://predicate2_value"
             }
         }
     }
     computed = suggest.get_instance_fields(query_params, elastic_search_item, class_schema)
     expected = [
         {
             "predicate_id": "http://predicate2",
             "predicate_title": "predicate2_title",
             "object_id": "http://predicate2_value",
             "object_title": "predicate2_value_label",
             "required": False
         }
     ]
     self.assertEqual(computed, expected)
Esempio n. 4
0
 def test_get_instance_fields_for_multiple_fields(self):
     class_schema = {
         "properties": {
             ":atContry": {"title": "Place is inside country"},
             ":hasMainLanguage": {"title": "Most common language in place"}
         }
     }
     elastic_search_item = {
         "fields": {
             ":atContry": "Peru",
             ":hasMainLanguage": "Spanish"
         }
     }
     computed = suggest.get_instance_fields(elastic_search_item, class_schema)
     expected = [
         {
             "predicate_id": ":hasMainLanguage",
             "predicate_title": "Most common language in place",
             "object_title": "Spanish",
             "required": False
         },
         {
             "predicate_id": ":atContry",
             "predicate_title": "Place is inside country",
             "object_title": "Peru",
             "required": False
         }
     ]
     self.assertEqual(computed, expected)
Esempio n. 5
0
 def test_get_instance_fields_for_property_with_multiple_objects(self):
     class_schema = {
         "properties": {
             ":hasParent": {
                 "title": "Father or mother"
             },
         }
     }
     elastic_search_item = {
         "fields": {":hasParent": ["Marry", "Harry"]}
     }
     computed = suggest.get_instance_fields(elastic_search_item, class_schema)
     expected = [
         {
             "predicate_id": ":hasParent",
             "predicate_title": "Father or mother",
             "object_title": "Marry",
             "required": False
         },
         {
             "predicate_id": ":hasParent",
             "predicate_title": "Father or mother",
             "object_title": "Harry",
             "required": False
         }
     ]
     self.assertEqual(computed, expected)
Esempio n. 6
0
 def test_get_instance_fields_for_not_required_object_property(self):
     class_schema = {
         "properties": {
             "http://predicate2": {"title": "predicate2_title"}
         }
     }
     elastic_search_item = {
         "fields": {
             "http://predicate2": {
                 "title": "predicate2_value_label",
                 "@id": "http://predicate2_value"
             }
         }
     }
     computed = suggest.get_instance_fields(elastic_search_item, class_schema)
     expected = [
         {
             "predicate_id": "http://predicate2",
             "predicate_title": "predicate2_title",
             "object_id": "http://predicate2_value",
             "object_title": "predicate2_value_label",
             "required": False
         }
     ]
     self.assertEqual(computed, expected)
Esempio n. 7
0
 def test_get_instance_fields_for_required_datatype_property(self):
     class_schema = {
         "properties": {
             "http://predicate1": {
                 "title": "predicate1_title",
                 "required": True
             },
         }
     }
     elastic_search_item = {
         "fields": {"http://predicate1": "predicate1_value"}
     }
     computed = suggest.get_instance_fields(elastic_search_item, class_schema)
     expected = [
         {
             "predicate_id": "http://predicate1",
             "predicate_title": "predicate1_title",
             "object_title": "predicate1_value",
             "required": True
         }
     ]
     self.assertEqual(computed, expected)