Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
software-dev-7054cem/Test/test_user.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
35 lines (28 sloc)
1.09 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from user import User | |
class TestUser(unittest.TestCase): | |
# standard built in method "setUp" for testing | |
def setUp(self): | |
self.__user = User() | |
self.__user.set_role("user") | |
self.__user.set_email("test@mail.com") | |
self.__user.set_phone("07427730650") | |
# test if role is correct | |
def test_get_role(self): | |
test_result = self.__user.get_role() | |
self.assertEqual(test_result, "user") | |
# test if email is correct | |
def test_get_email(self): | |
test_result = self.__user.get_email() | |
self.assertEqual(test_result, "test@mail.com") | |
# test if phone exists and is correct | |
def test_phone_exists(self): | |
test_result = self.__user.get_phone() | |
self.assertIsNotNone(test_result) | |
self.assertEqual(test_result, "07427730650") | |
# test that it doesn't have "managers" composite pattern | |
def test_has_not_manager(self): | |
# use built in hasattr() to check if attribute | |
# get_managers exist | |
test_result = hasattr(self.__user, "get_managers") | |
self.assertIs(test_result, False) |