示例#1
0
    def test_location_hierarchy_created(self) -> None:
        fetched_parent = get_location(client=self.client,
                                      location_hirerchy=[("City", "parent")])
        self.assertEqual(fetched_parent.name, "parent")
        fetched_child_location1 = get_location(client=self.client,
                                               location_hirerchy=[("City",
                                                                   "child1")])
        self.assertEqual(self.location_child_1, fetched_child_location1)

        fetcheed_child_location2 = get_location(client=self.client,
                                                location_hirerchy=[("City",
                                                                    "child2")])
        self.assertEqual(self.location_child_2, fetcheed_child_location2)
示例#2
0
 def test_get_location_children(self) -> None:
     created_locations_arr = {
         self.location_child_1.id, self.location_child_2.id
     }
     parent_location = get_location(self.client, [("City", "parent")])
     fetch_locations = get_location_children(self.client,
                                             parent_location.id)
     fetch_locations_arr = {location.id for location in fetch_locations}
     self.assertEqual(created_locations_arr, fetch_locations_arr)
示例#3
0
 def test_location_moved(self) -> None:
     move_location(
         client=self.client,
         location_id=self.location_2.id,
         new_parent_id=self.location_1.id,
     )
     moved_location = get_location(client=self.client,
                                   location_hirerchy=[("City", "Lima1"),
                                                      ("City", "Lima2")])
     self.assertEqual(self.location_2.id, moved_location.id)
示例#4
0
 def test_location_edited(self) -> None:
     edit_location(
         self.client,
         self.location_1,
         "Lima4",
         10,
         20,
         None,
         {"Contact": "*****@*****.**"},
     )
     edited_location = get_location(self.client, [("City", "Lima4")])
     # TODO(T63055774): update test to check updated properties
     self.assertEqual(self.location_1.id, edited_location.id)
示例#5
0
 def test_location_edited(self) -> None:
     edit_location(
         client=self.client,
         location=self.location_1,
         new_name="Lima4",
         new_lat=10,
         new_long=20,
         new_external_id=None,
         new_properties={"Contact": "*****@*****.**"},
     )
     edited_location = get_location(client=self.client,
                                    location_hirerchy=[("City", "Lima4")])
     # TODO(T63055774): update test to check updated properties
     self.assertEqual(self.location_1.id, edited_location.id)
示例#6
0
    def test_location_upload_folder(self) -> None:
        fetch_location = get_location(self.client, [("City", "Lima1")])
        self.assertEqual(self.location_1, fetch_location)
        for suffix in self.suffixes:
            with open(
                    os.path.join(self.tmpdir, ".".join(["temp_file", suffix])),
                    "wb") as tmp:
                tmp.write(b"TEST DATA FILE")
        add_files(self.client, self.tmpdir, "LOCATION", self.location_1.id,
                  "test_category")

        docs = get_location_documents(self.client, self.location_1)
        self.assertEqual(len(docs), len(self.suffixes))
        for doc in docs:
            self.assertEqual(doc.category, "test_category")
            delete_document(self.client, doc)
示例#7
0
 def test_location_moved(self) -> None:
     move_location(self.client, self.location_2.id, self.location_1.id)
     moved_location = get_location(self.client, [("City", "Lima1"),
                                                 ("City", "Lima2")])
     self.assertEqual(self.location_2.id, moved_location.id)
示例#8
0
 def test_location_created(self) -> None:
     fetch_location = get_location(self.client, [("City", "Lima1")])
     self.assertEqual(self.location_1, fetch_location)