示例#1
0
 def test_add_folder(self):
     folder_name = "TestFolder"
     folders._add_folder_to_user(self.user.user_id, folder_name)
     expected = os.path.join(
         path_utils.get_users_root_folder(self.user.user_id), folder_name)
     self.assertTrue(os.path.exists(expected))
     folder_entry = database.Folder.get_by_user_and_name(
         self.user.user_id, folder_name)
     self.assertIsInstance(folder_entry, database.Folder)
示例#2
0
 def test_create_pull2(self):
     self.user = h_register_dummy_user_device_client()
     interface.add_sync_folder(self.folder1_abs_local_path, "folder1")
     file_path = os.path.join(self.folder1_abs_local_path, "dummy.txt")
     with open(file_path, "w") as f:
         f.write("Hello World")
     time.sleep(1)
     synchronization.full_synchronize()
     time.sleep(2)
     expected_path = os.path.join(
         path_utils.get_users_root_folder(self.user.user_id),
         "folder1/dummy.txt")
     self.assertTrue(os.path.exists(expected_path),
                     "dummy file is not pulled to server!")
示例#3
0
def _get_file_path(user_id: int, device_id: int) -> str:
    user_path = path_utils.get_users_root_folder(user_id)
    file_path = server_paths.normalize_path(user_path,
                                            get_file_name(device_id))
    return file_path
示例#4
0
def get_changes(dest_path: str) -> net.File:
    user = net_interface.get_user()
    user_path = path_utils.get_users_root_folder(user.user_id)
    changes_path = server_paths.normalize_path(user_path, f"changes_{user.device_id}.json")
    return net.File(changes_path, dest_path)
示例#5
0
 def test_create_physical_folder(self):
     folder_name = "TestFolder"
     folders._create_physical_folder(self.user.user_id, folder_name)
     expected = os.path.join(
         path_utils.get_users_root_folder(self.user.user_id), folder_name)
     self.assertTrue(os.path.exists(expected))
示例#6
0
def _create_physical_folder(user_id: int, folder_name: str):
    """Creates a new folder at the harddrive."""
    users_root = path_utils.get_users_root_folder(user_id)
    new_folder_path = paths.normalize_path(users_root, folder_name)
    os.mkdir(new_folder_path)
示例#7
0
def create_folder_for_new_user(user: User) -> None:
    """For every user a folder in the root folder is created. Inside this new  folder every synchronized folder is
    stored"""
    users_root = path_utils.get_users_root_folder(user.user_id)
    assert not os.path.exists(users_root), "User folder already exists!"
    os.makedirs(str(users_root))