def test_common_path_when_duplicate_entries_of_single_path(self): d = DependencyList() files = [ "/users/joebloggs/tmp/foo.txt", "/users/joebloggs/tmp/foo.txt" ] d.add(*files, must_exist=False) self.assertEqual(d.common_path(), "/users/joebloggs/tmp/foo.txt")
def test_common_path_when_one_path_is_the_common_path(self): d = DependencyList() files = [ "/users/joebloggs/tmp", "/users/joebloggs/tmp/bolly/operation", "/users/joebloggs/tmp/stay/go" ] d.add(*files, must_exist=False) self.assertEqual(d.common_path(), "/users/joebloggs/tmp")
def test_common_path(self): d = DependencyList() files = [ "/users/joebloggs/tmp/foobar/test", "/users/joebloggs/tmp/baz/fripp", "/users/joebloggs/tmp/elephant/corner" ] d.add(*files, must_exist=False) self.assertEqual(d.common_path(), "/users/joebloggs/tmp")
def test_common_path_when_common_prefix_in_filename(self): d = DependencyList() files = [ "/users/joebloggs/tmp/dissention/perfect", "/users/joebloggs/tmp/disagreement/crimson", "/users/joebloggs/tmp/diatribe/belew" ] d.add(*files, must_exist=False) self.assertEqual(d.common_path(), "/users/joebloggs/tmp")
def test_common_path_when_lowest_path_is_the_common_path(self): d = DependencyList() files = [ "/users/joebloggs/tmp/foo.txt", "/users/joebloggs/tmp/modelman.jpg", "/users/joebloggs/tmp/ration.cpp", "/users/joebloggs/tmp/bill.project" ] d.add(*files, must_exist=False) self.assertEqual(d.common_path(), "/users/joebloggs/tmp")
def _get_output_directory(self): """Get the common path for all image output paths. Also return the individual paths as they may need to be created. """ out_paths = DependencyList() images = ix.api.OfObjectArray() self.node.get_attribute("images").get_values(images) for image in images: directory = os.path.dirname( image.get_attribute("save_as").get_string()) out_paths.add(directory, must_exist=False) return { "common_path": out_paths.common_path(), "output_paths": list(out_paths) }
def test_common_path_is_slash_when_root(self): d = DependencyList() files = ["/users/joebloggs/tmp/foo.txt", "/dev/joebloggs/tmp/foo.txt"] d.add(*files, must_exist=False) self.assertEqual(d.common_path(), "/")
def test_common_path_is_none_when_no_entries(self): d = DependencyList() self.assertIsNone(d.common_path())