def test_save_cred(self): """ test_save_cred to check if the initialized object is saved to credentials_info """ self.new_cred = Credentials("komo","james","IG","pswd001") self.new_cred.save_cred() self.assertEqual(len(Credentials.credentials_info),5)
def test_setUp(self): """ test_setUp to create a new Credentials object to begin tests """ self.new_cred = Credentials("Simon", "SPG", "Instagram", "W3w3n!mkenya")
def test_save_cred(self): """ test_save_cred to check if the initialized object is saved to credentials_info """ self.new_cred = Credentials("Simon", "SPG", "Instagram", "W3w3n!mkenya") self.new_cred.save_cred() self.assertEqual(len(Credentials.credentials_info), 3)
def test_show_credentials(self): """ test_show_credentials test to check if credentials saved is displayed """ self.new_cred = Credentials("komo","james","IG","pswd001") self.new_cred.save_cred() self.another_cred = Credentials("komo","james","IG","pswd001") self.another_cred.save_cred() self.assertEqual(len(Credentials.show_credentials(self.new_cred.username)),1)
def test_init(self): """ test_init to check if the Credentials objects are initialized correctly """ self.new_cred = Credentials("komo","james","IG","pswd001") self.assertEqual(self.new_cred.name, "komo") self.assertEqual(self.new_cred.username, "james") self.assertEqual(self.new_cred.platform, "IG") self.assertEqual(self.new_cred.pwd, "pswd001")
def test_init(self): """ test_init to check if the Credentials objects are initialized correctly """ self.new_cred = Credentials("Simon", "SPG", "Instagram", "W3w3n!mkenya") self.assertEqual(self.new_cred.name, "Simon") self.assertEqual(self.new_cred.username, "SPG") self.assertEqual(self.new_cred.platform, "Instagram") self.assertEqual(self.new_cred.pwd, "W3w3n!mkenya")
def test_show_credentials(self): """ test_show_credentials test to check if credentials saved is displayed """ self.new_cred = Credentials("Simon", "SPG", "Instagram", "W3w3n!mkenya") self.new_cred.save_cred() self.another_cred = Credentials("Simon", "SPG", "Gmail", "W3w3n!mkenya") self.another_cred.save_cred() self.assertEqual( len(Credentials.show_credentials(self.new_cred.username)), 1)
def test_del_cred(self): """ test_del_cred test to delete credentials from the credentials list """ Credentials.credentials_info = [] self.new_cred = Credentials("komo","james","IG","pswd001") self.new_cred.save_cred() IG = Credentials("komo","james","IG","pswd001") IG.save_cred() del_item = Credentials.find_platform('IG') self.assertEqual(Credentials.del_cred(del_item),"Deleted")
def test_del_cred(self): """ test_del_cred test to delete credentials from the credentials list """ Credentials.credentials_info = [] self.new_cred = Credentials("billo", "diallo", "BD", "pswd001") self.new_cred.save_cred() BD = Credentials("billo", "diallo", "BD", "pswd001") BD.save_cred() del_item = Credentials.find_platform('IG') self.assertEqual(Credentials.del_cred(del_item), "Deleted")
def test_del_cred(self): """ test_del_cred test to delete credentials from the credentials list """ Credentials.credentials_info = [] self.new_cred = Credentials("Simon", "SPG", "Instagram", "W3w3n!mkenya") self.new_cred.save_cred() snapchat = Credentials("Simon", "SPG", "Snapchat", "W3w3n!mkenya") snapchat.save_cred() del_item = Credentials.find_platform('Snapchat') self.assertEqual(Credentials.del_cred(del_item), "Deleted")
def test_find_platform(self): """ test_find_platform test to search credentials per account """ self.new_cred = Credentials("komo","james","IG","pswd001") self.new_cred.save_cred() IG = Credentials("komo","james","IG","pswd001") IG.save_cred() self.assertEqual(Credentials.find_platform('IG'),IG)
def test_find_platform(self): """ test_find_platform test to search credentials per account """ self.new_cred = Credentials("billo", "diallo", "BD", "pswd001") self.new_cred.save_cred() BD = Credentials("billo", "diallo", "BD", "pswd001") BD.save_cred() self.assertEqual(Credentials.find_platform('BD'), BD)
def test_find_platform(self): """ test_find_platform test to search credentials per platform """ self.new_cred = Credentials("Simon", "SPG", "Instagram", "W3w3n!mkenya") self.new_cred.save_cred() snapchat = Credentials("Simon", "SPG", "Snapchat", "W3w3n!mkenya") snapchat.save_cred() self.assertEqual(Credentials.find_platform('Snapchat'), snapchat)
def test_auth_check(self): """ test_auth_check test case to test if the user provided correct information """ self.new_user = Users("Simon", "Gatheru", "W3w3n!mkenya") self.new_user.create_user() another_user = Users("Twende", "Kazi", "mkenya") another_user.create_user() for cred in Users.user_info: if cred.first == another_user.first and cred.password == another_user.password: identity = another_user.first return identity self.assertEqual( identity, Credentials.user_check(another_user.first, another_user.password))
class TestCredentials(unittest.TestCase): """ Test class that defines test cases for the Credentials behaviour Args: unittest.TestCase: Class from the unittest module to create unit tests """ def test_auth_check(self): """ test_auth_check test case to test if the user provided correct information """ self.new_user = Users("komo","James","pswd002") self.new_user.create_user() another_user = Users("user2","othername","pswd003") another_user.create_user() for cred in Users.user_info: if cred.first == another_user.first and cred.password == another_user.password: identity = another_user.first return identity def test_setUp(self): """ test_setUp to create a new Credentials object to begin tests """ self.new_cred = Credentials("komo","james","IG","pswd001") def test_init(self): """ test_init to check if the Credentials objects are initialized correctly """ self.new_cred = Credentials("komo","james","IG","pswd001") self.assertEqual(self.new_cred.name, "komo") self.assertEqual(self.new_cred.username, "james") self.assertEqual(self.new_cred.platform, "IG") self.assertEqual(self.new_cred.pwd, "pswd001") def test_save_cred(self): """ test_save_cred to check if the initialized object is saved to credentials_info """ self.new_cred = Credentials("komo","james","IG","pswd001") self.new_cred.save_cred() self.assertEqual(len(Credentials.credentials_info),5) def tearDowm(self): """ reinitializes the credentials_info list to its empty state """ Credentials.credentials_info = [] def test_show_credentials(self): """ test_show_credentials test to check if credentials saved is displayed """ self.new_cred = Credentials("komo","james","IG","pswd001") self.new_cred.save_cred() self.another_cred = Credentials("komo","james","IG","pswd001") self.another_cred.save_cred() self.assertEqual(len(Credentials.show_credentials(self.new_cred.username)),1) def test_find_platform(self): """ test_find_platform test to search credentials per account """ self.new_cred = Credentials("komo","james","IG","pswd001") self.new_cred.save_cred() IG = Credentials("komo","james","IG","pswd001") IG.save_cred() self.assertEqual(Credentials.find_platform('IG'),IG) def test_del_cred(self): """ test_del_cred test to delete credentials from the credentials list """ Credentials.credentials_info = [] self.new_cred = Credentials("komo","james","IG","pswd001") self.new_cred.save_cred() IG = Credentials("komo","james","IG","pswd001") IG.save_cred() del_item = Credentials.find_platform('IG') self.assertEqual(Credentials.del_cred(del_item),"Deleted")
def test_setUp(self): """ test_setUp to create a new Credentials object to begin tests """ self.new_cred = Credentials("billo", "diallo", "BD", "pswd001")
def user_check(first,pwd): ''' Does an authorization check prior to creating any credentials ''' return Credentials.user_check(first,pwd)
def show_cred(username): ''' Displays saved credentials ''' return Credentials.show_credentials(username)
class TestCredentials(unittest.TestCase): """ Test class that defines test cases for the Credentials behaviour Args: unittest.TestCase: Class from the unittest module to create unit tests """ def test_auth_check(self): """ test_auth_check test case to test if the user provided correct information """ self.new_user = Users("Simon", "Gatheru", "W3w3n!mkenya") self.new_user.create_user() another_user = Users("Twende", "Kazi", "mkenya") another_user.create_user() for cred in Users.user_info: if cred.first == another_user.first and cred.password == another_user.password: identity = another_user.first return identity self.assertEqual( identity, Credentials.user_check(another_user.first, another_user.password)) def test_setUp(self): """ test_setUp to create a new Credentials object to begin tests """ self.new_cred = Credentials("Simon", "SPG", "Instagram", "W3w3n!mkenya") def test_init(self): """ test_init to check if the Credentials objects are initialized correctly """ self.new_cred = Credentials("Simon", "SPG", "Instagram", "W3w3n!mkenya") self.assertEqual(self.new_cred.name, "Simon") self.assertEqual(self.new_cred.username, "SPG") self.assertEqual(self.new_cred.platform, "Instagram") self.assertEqual(self.new_cred.pwd, "W3w3n!mkenya") def test_save_cred(self): """ test_save_cred to check if the initialized object is saved to credentials_info """ self.new_cred = Credentials("Simon", "SPG", "Instagram", "W3w3n!mkenya") self.new_cred.save_cred() self.assertEqual(len(Credentials.credentials_info), 3) def tearDowm(self): """ reinitializes the credentials_info list to its empty state """ Credentials.credentials_info = [] def test_show_credentials(self): """ test_show_credentials test to check if credentials saved is displayed """ self.new_cred = Credentials("Simon", "SPG", "Instagram", "W3w3n!mkenya") self.new_cred.save_cred() self.another_cred = Credentials("Simon", "SPG", "Gmail", "W3w3n!mkenya") self.another_cred.save_cred() self.assertEqual( len(Credentials.show_credentials(self.new_cred.username)), 1) def test_find_platform(self): """ test_find_platform test to search credentials per platform """ self.new_cred = Credentials("Simon", "SPG", "Instagram", "W3w3n!mkenya") self.new_cred.save_cred() snapchat = Credentials("Simon", "SPG", "Snapchat", "W3w3n!mkenya") snapchat.save_cred() self.assertEqual(Credentials.find_platform('Snapchat'), snapchat) def test_del_cred(self): """ test_del_cred test to delete credentials from the credentials list """ Credentials.credentials_info = [] self.new_cred = Credentials("Simon", "SPG", "Instagram", "W3w3n!mkenya") self.new_cred.save_cred() snapchat = Credentials("Simon", "SPG", "Snapchat", "W3w3n!mkenya") snapchat.save_cred() del_item = Credentials.find_platform('Snapchat') self.assertEqual(Credentials.del_cred(del_item), "Deleted")
def test_setUp(self): """ test_setUp to create a new Credentials object to begin tests """ self.new_cred = Credentials("komo","james","IG","pswd001")
def password_gen(size): ''' Generates a random password_gen ''' random = Credentials.password_gen(size) return random
def create_cred(name,username,platform,pwd): ''' Creates credentials to be saved ''' create_instance = Credentials(name,username,platform,pwd) return create_instance
def show_cred(username): ''' Shows credentials saved ''' return Credentials.show_credentials(username)
def user_check(first, pwd): ''' Checks whether user exists before creating any new credentials ''' return Credentials.user_check(first, pwd)
def save_cred(cred): ''' Saves created credentials ''' Credentials.save_cred(cred)