def add_folder(folder_name: str) -> bool: if not gen_json.can_folder_be_added( server_paths.NormalizedPath(folder_name)): return False data = _get_json_data() new_folder_entry = {"changes": {}} data[folder_name] = new_folder_entry _set_json_data(data) return True
def test_add_change_entry(self): path = server_paths.NormalizedPath("folder_1") server_json.add_folder(path) rel_file_path = server_paths.normalize_path("test.txt") server_json.add_change_entry(path, rel_file_path, gen_json.ACTION_PULL) folder_entry = gen_json.get_folder_entry(path) changes = folder_entry["changes"] self.assertEqual(1, len(changes))
def test_add_folder_existing(self): path = server_paths.NormalizedPath("folder_1") added = server_json.add_folder(path) self.assertTrue(added) added = server_json.add_folder(path) self.assertFalse(added)
def test_remove_folder(self): path = server_paths.NormalizedPath("folder_1") server_json.add_folder(path) server_json.remove_folder(path) data = server_json._get_json_data() self.assertEqual({}, data)
def test_add_folder(self): path = server_paths.NormalizedPath("folder_1") server_json.add_folder(path) data = server_json._get_json_data() expected = {path: {"changes": {}}} self.assertEqual(expected, data)