def test_erase_data_files(self): test_diary_control = DiaryControl(self.conf_path) test_diary_control.create_owner(login=LOGIN1, password=PASSWORD1) test_diary_control.create_owner(login=LOGIN2, password=PASSWORD2) test_diary_control.save_owners_to_disc() owners_path = list( map( lambda x: os.path.join(DiaryControl.cfg.dir_path, x) + DiaryControl.cfg.data_extension, [LOGIN1, LOGIN2])) for login_str, file_path_full in zip([LOGIN1, LOGIN2], owners_path): test_diary_control.erase_owner_data_files(login_str) self.assertFalse(os.path.exists(file_path_full))
def test_save_owners_to_disc(self): test_diary_control = DiaryControl(self.conf_path) test_diary_control.create_owner(login=LOGIN1, password=PASSWORD1) test_diary_control.create_owner(login=LOGIN2, password=PASSWORD2) test_diary_control.save_owners_to_disc() owners_path = list( map( lambda x: os.path.join(DiaryControl.cfg.dir_path, x) + DiaryControl.cfg.data_extension, [LOGIN1, LOGIN2])) for file_path_full in owners_path: self.assertTrue(os.path.exists(file_path_full)) os.remove(file_path_full)
def test_load_owner_from_disk(self): test_diary_control = DiaryControl(self.conf_path) test_diary_control.create_owner(login=LOGIN1, password=PASSWORD1) test_diary_control.create_owner(login=LOGIN2, password=PASSWORD2) test_diary_control.save_owners_to_disc() owners = [] for login_str in [LOGIN1, LOGIN2]: owners.append(test_diary_control.load_owner_from_disc(login_str)) self.assertIsInstance(owners[-1], Owner) self.assertEqual(owners[-1].login, login_str) self.assertIsNone(owners[-1].name) test_diary_control.erase_owner_data_files(login_str)