def setUp(self): """ Method that runs before each individual details test methods run. """ self.new_detail = Details('Facebook', 'KilewaGeorge', 'StAiGhTOrSyoki@#@&')
def test_save_many_accounts(self): ''' test to check if we can save multiple details objects to our details list ''' self.new_detail.save_details() test_detail = Details("Twitter", "georgekilewa", "GeO%$#85Hj") test_detail.save_details() self.assertEqual(len(Details.details_list), 2)
def test__detail_exist(self): """ test to check if we can return a true or false based on whether we find or can't find the detail. """ self.new_detail.save_details() the__detail = Details("Twitter", "georgekilewa", "GeO%$#85Hj") the__detail.save_details() detail_is_found = Details.if_detail_exist("Twitter") self.assertTrue(detail_is_found)
def test_delete_detail(self): """ test method to test if we can remove an account details from our details_list """ self.new_detail.save_details() test_detail = Details("Twitter", "georgekilewa", "GeO%$#85Hj") test_detail.save_details() self.new_detail.delete_details() self.assertEqual(len(Details.details_list), 1)
def test_find_details(self): """ test to check if we can find a detail entry by account name and display the details. """ self.new_detail.save_details() test_detail = Details("Twitter", "georgekilewa", "GeO%$#85Hj") test_detail.save_details() the_detail = Details.find_details("Twitter") self.assertEqual(the_detail.account, test_detail.account)
def copy_password(account): """ A funct that copies the password using the pyperclip framework We import the framework then declare a function that copies the emails. """ return Details.copy_password(account)
def check_details(account): """ Function that check if a detail exists with that account name and return true or false """ return Details.if_detail_exist(account)
def find_detail(account): """ Function that finds a details by an account name and returns the details that belong to that account """ return Details.find_details(account)
def display_accounts_details(): """ Function that returns all the saved details. """ return Details.display_details()
def create_new_detail(account,userName,password): """ Function that creates new details for a given user account """ new_detail = Details(account,userName,password) return new_detail
def login_user(username,password): """ function that checks whether a user exist and then login the user in. """ check_user = Details.verify_user(username,password) return check_user
class TestDetails(unittest.TestCase): """ A test class that defines test cases for details class """ def setUp(self): """ Method that runs before each individual details test methods run. """ self.new_detail = Details('Facebook', 'KilewaGeorge', 'StAiGhTOrSyoki@#@&') def test_init(self): """ Test case to check if a new Details instance has been initialized correctly """ self.assertEqual(self.new_detail.account, 'Facebook') self.assertEqual(self.new_detail.userName, 'KilewaGeorge') self.assertEqual(self.new_detail.password, 'StAiGhTOrSyoki@#@&') def save_detail_test(self): """ test case to test if the detail object is saved into the details list. """ self.new_detail.save_details() self.assertEqual(len(Details.details_list), 1) def tearDown(self): ''' method that does clean up after each test case has run. ''' Details.details_list = [] def test_save_many_accounts(self): ''' test to check if we can save multiple details objects to our details list ''' self.new_detail.save_details() test_detail = Details("Twitter", "georgekilewa", "GeO%$#85Hj") test_detail.save_details() self.assertEqual(len(Details.details_list), 2) def test_delete_detail(self): """ test method to test if we can remove an account details from our details_list """ self.new_detail.save_details() test_detail = Details("Twitter", "georgekilewa", "GeO%$#85Hj") test_detail.save_details() self.new_detail.delete_details() self.assertEqual(len(Details.details_list), 1) def test_find_details(self): """ test to check if we can find a detail entry by account name and display the details. """ self.new_detail.save_details() test_detail = Details("Twitter", "georgekilewa", "GeO%$#85Hj") test_detail.save_details() the_detail = Details.find_details("Twitter") self.assertEqual(the_detail.account, test_detail.account) def test__detail_exist(self): """ test to check if we can return a true or false based on whether we find or can't find the detail. """ self.new_detail.save_details() the__detail = Details("Twitter", "georgekilewa", "GeO%$#85Hj") the__detail.save_details() detail_is_found = Details.if_detail_exist("Twitter") self.assertTrue(detail_is_found) def test_display_all_saved_details(self): ''' method that displays all the details that has been saved by the user ''' self.assertEqual(Details.display_details(), Details.details_list)
def test_display_all_saved_details(self): ''' method that displays all the details that has been saved by the user ''' self.assertEqual(Details.display_details(), Details.details_list)