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_staff.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
39 lines (31 sloc)
1.32 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 staff import Staff | |
class TestStaff(unittest.TestCase): | |
# standard built in method "setUp" for testing | |
def setUp(self): | |
self.__user = Staff() | |
self.__user.set_role("staff") | |
self.__user.set_email("staff@mail.com") | |
self.__user.add_manager("manager@mail.com") | |
# test if role is correct | |
def test_get_role(self): | |
test_result = self.__user.get_role() | |
self.assertEqual(test_result, "staff") | |
# test if email is correct | |
def test_get_email(self): | |
test_result = self.__user.get_email() | |
self.assertEqual(test_result, "staff@mail.com") | |
# test that it doesn't have "managers" composite pattern | |
def test_phone_is_null(self): | |
# use built in hasattr() to check if attribute | |
# get_phone exist | |
test_result = hasattr(self.__user, "get_phone") | |
self.assertIs(test_result, False) | |
# test that it doesn't have "managers" composite pattern | |
def test_manager_exists(self): | |
test_result = self.__user.get_managers_email() | |
self.assertEqual(test_result, ["manager@mail.com"]) | |
def test_manager_add(self): | |
self.__user.add_manager("manager2@mail.com") | |
test_result = self.__user.get_managers_email() | |
self.assertEqual(test_result, ["manager@mail.com","manager2@mail.com"]) |