Esempio n. 1
0
class TestCredentials(unittest.TestCase):
    '''
    Test class that defines the test cases for creating and authenticating credentials
    '''
    def setUp(self):
        '''
        Setting up the structure before each test
        '''
        self.new_user = Credentials(1, "martin", "mwikia")

    def tearDown(self):
        '''
        Cleans up after each test has run
        '''
        Credentials.users_list = []

    def test_init(self):
        '''
        Test case to test if the case has been initialized properly
        '''
        self.assertEqual(self.new_user.recognise, 1)
        self.assertEqual(self.new_user.username, "martin")
        self.assertEqual(self.new_user.password, "mwikia")

    def test_authenticate(self):
        '''
        Testing to check if the authenticate function can sign in a user properly
        '''
        self.new_user.create_account()
        test_account = Credentials(1, "Test", "Password")
        test_account.create_account()

        found_user = Credentials.authenticate_account("Test", "Password")
        self.assertEqual(found_user.recognise, test_account.recognise)
Esempio n. 2
0
    def test_authenticate(self):
        '''
        Testing to check if the authenticate function can sign in a user properly
        '''
        self.new_user.create_account()
        test_account = Credentials(1, "Test", "Password")
        test_account.create_account()

        found_user = Credentials.authenticate_account("Test", "Password")
        self.assertEqual(found_user.identify, test_account.identify)
Esempio n. 3
0
class TestCredentials(unittest.TestCase):
    '''
    Test class for creating and authenticating credentials
    '''
    def setUp(self):
        '''
        Setting up the structure before each test
        '''
        self.new_user = Credentials(1, "winnie", "mwikali")

    def tearDown(self):
        '''
        Cleans up after each test has run
        '''
        Credentials.users_list = []

    def test_init(self):
        '''
        Test case to test if the case has been initialized properly
        '''
        self.assertEqual(self.new_user.identify, 1)
        self.assertEqual(self.new_user.user_name, "")
        self.assertEqual(self.new_user.password, "")

    def test_create(self):
        '''
        Testing if the new credential is saved into the list
        '''
        self.new_user.create_account()
        self.assertEqual(len(Credentials.users_list), 1)

    def test_authenticate(self):
        '''
        Testing to check if the authenticate function can sign in a user properly
        '''
        self.new_user.create_account()
        test_account = Credentials(1, "Test", "Password")
        test_account.create_account()

        found_user = Credentials.authenticate_account("Test", "Password")
        self.assertEqual(found_user.identify, test_account.identify)