Skip to content
Permalink
f893ee80fc
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
39 lines (31 sloc) 1.32 KB
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"])