def test_copy_pass(self): ''' Testing if password has been copied ''' self.new_userdata.save_website() UserData.copy_pass(1,"Michel") self.assertEqual(self.new_userdata.webpass,pyperclip.paste())
def test_userdata_exists(self): ''' Testing if method for checking userdata works ''' self.new_userdata.save_website() test_userdata = UserData(1,"Michel","twitter.com","yolo") test_userdata.save_website() userdata_exists = UserData.existing_userdata("Michel") self.assertTrue(userdata_exists)
def test_display_userdata(self): ''' method that returns a list of all websites saved ''' self.new_userdata.save_website() test_userdata = UserData(1,"Michel","twitter.com","yolo") test_userdata.save_website() userdata_found = UserData.display_userdata(1,"Michel") self.assertEqual(userdata_found.website, test_userdata.website)
def copy_pass(number, count): ''' Function that copies password to clipboard ''' UserData.copy_pass(number, count)
def userdata_existing(userdata): ''' Function that checks if userdata exists ''' return UserData.existing_userdata(userdata)
def display_userdata(userdata, number): ''' Function that displays user data ''' return UserData.display_userdata(userdata, number)
def my_new_userdata(newuser_id, username, website, webpass): ''' Function that creates new userdata ''' new_userdata = UserData(newuser_id, username, website, webpass) return new_userdata
def setUp(self): ''' Set up method to run before each test cases. ''' self.new_userdata = UserData(1,"Michel","twitter.com","yolo")
class TestUserData(unittest.TestCase): def setUp(self): ''' Set up method to run before each test cases. ''' self.new_userdata = UserData(1,"Michel","twitter.com","yolo") def tearDown(self): ''' tearDown method that does clean up after each test case has run ''' UserData.userdata_list = [] def test_init(self): ''' Test class that defines test case for website and logging in ''' self.assertEqual(self.new_userdata.id, 1) self.assertEqual(self.new_userdata.username,"Michel") self.assertEqual(self.new_userdata.website,"twitter.com") self.assertEqual(self.new_userdata.webpass,"yolo") def test_save_website(self): ''' tests case to test if website and webpass can be saved ''' self.new_userdata.save_website() #saving new website self.assertEqual(len(UserData.userdata_list),1) def test_display_userdata(self): ''' method that returns a list of all websites saved ''' self.new_userdata.save_website() test_userdata = UserData(1,"Michel","twitter.com","yolo") test_userdata.save_website() userdata_found = UserData.display_userdata(1,"Michel") self.assertEqual(userdata_found.website, test_userdata.website) def test_userdata_exists(self): ''' Testing if method for checking userdata works ''' self.new_userdata.save_website() test_userdata = UserData(1,"Michel","twitter.com","yolo") test_userdata.save_website() userdata_exists = UserData.existing_userdata("Michel") self.assertTrue(userdata_exists) def test_copy_pass(self): ''' Testing if password has been copied ''' self.new_userdata.save_website() UserData.copy_pass(1,"Michel") self.assertEqual(self.new_userdata.webpass,pyperclip.paste())