def test_load(self): test_service = service.Service() test_service.service_name = "Is" test_service.username = "******" test_service.password = "******" test_service2 = service.Service() dic = { "service_name": test_service.service_name, "username": test_service.username, "password": test_service.password } test_service2.load(dic) self.assertEqual(test_service.service_name, test_service2.service_name) self.assertEqual(test_service.username, test_service2.username) self.assertEqual(test_service.password, test_service2.password)
def test_add_service(self): test_service = service.Service() db = database.Database() db.add_service(test_service) self.assertEqual(test_service.service_name, db.services[0].service_name) self.assertEqual(test_service.username, db.services[0].username) self.assertEqual(test_service.password, db.services[0].password)
def test_modifying_service(self): service1 = service.Service() service1.service_name = "ser" service1.username = "******" service1.password = "******" self.assertEqual(service1.service_name, "ser") self.assertEqual(service1.username, "use") self.assertEqual(service1.password, "pas")
def test_load(self): db = database.Database() dic = { "name": "Hey", "services": [service.Service()] } db.load(dic) self.assertEqual("Hey", db.name) self.assertEqual("ServiceName", db.services[0].service_name) self.assertEqual("Username", db.services[0].username) self.assertEqual("Password", db.services[0].password)
def test_custom_service(self): service1 = service.Service("service", "user", "pass") self.assertEqual(service1.service_name, "service") self.assertEqual(service1.username, "user") self.assertEqual(service1.password, "pass")
def test_simple_service(self): service1 = service.Service() self.assertEqual(service1.service_name, self.ref_service.service_name) self.assertEqual(service1.username, self.ref_service.username) self.assertEqual(service1.password, self.ref_service.password)
def setUp(self): self.ref_service = service.Service()
def create_service(): data = get_service_data() serv = service.Service() serv.load(data) return serv
def perform_actions(db: database.Database, password: str): global buff_size cont = True while cont: services_number = len(db.services) choice = get_input_with_choices( "What do you want to do ? quit (q), edit database (e), load new db (l), " "get password (g): ", ['q', 'e', 'l', 'g']) if choice == 'q': clear() sys.exit(0) elif choice == 'e': choice = get_input_with_choices( "Edit service (e), remove service (r), add service (a), change login " "information (l), delete db (d), " "cancel (c): ", ['e', 'r', 'a', 'd', 'c', 'l']) if choice == 'e': if services_number > 0: choices = [str(c) for c in range(1, services_number + 1)] choice = get_input_with_choices( "Which one (1-" + str(services_number) + "): ", choices) data = get_service_data() db.load_service(int(choice) - 1, data) storage.write(password, db, "databases/" + db.name + ".db") display_db(db) else: print("No service available.") buff_size += 1 elif choice == 'r': if services_number > 0: choices = [str(c) for c in range(1, services_number + 1)] choice = get_input_with_choices( "Which one (1-" + str(services_number) + "): ", choices) db.remove_service(int(choice) - 1) storage.write(password, db, "databases/" + db.name + ".db") display_db(db) else: print("No service available.") buff_size += 1 elif choice == 'a': data = get_service_data() serv = service.Service() serv.load(data) db.add_service(serv) storage.write(password, db, "databases/" + db.name + ".db") display_db(db) elif choice == 'd': if query_yes_no("Are you sure you want to delete database \"" + db.name + "\" ?"): storage.delete("databases/" + db.name + ".db") del db cont = False if query_yes_no("Quit ?"): sys.exit(0) elif choice == 'l': choice = get_input_with_choices( "Change name (n), password (p), both (b), cancel (c): ", ['n', 'p', 'b', 'c']) name = None pword = None if choice == 'n': name = get_input("New name: ") elif choice == 'p': pword = get_password("New password: "******"New name: ") pword = get_password("New password: "******"databases/" + db.name + ".db") db.name = name if name is not None else db.name pword = pword if pword is not None else password storage.write(pword, db, "databases/" + db.name + ".db") display_db(db) elif choice == 'l': del db cont = False clear() return True elif choice == 'g': if services_number > 0: choices = [str(c) for c in range(1, services_number + 1)] choice = get_input_with_choices( "Which one (1-" + str(services_number) + "): ", choices) r = tkinter.Tk() r.withdraw() r.clipboard_clear() r.clipboard_append(db.services[int(choice) - 1].password) else: print("No service available.") buff_size += 1 return False