コード例 #1
0
    def test_apply_raise(self):
        self.emp1 = Employee("Thomas", "Stoetzner", 5000)
        self.emp2 = Employee("Jakob", "Klamm", 30)

        self.emp1.apply_raise()
        self.emp2.apply_raise()

        self.assertEqual(self.emp1.pay, 5250)
        self.assertEqual(self.emp2.pay, 31)
コード例 #2
0
    def test_fullname(self):

        self.emp1 = Employee("Thomas", "Stoetzner", 5000)
        self.emp2 = Employee("Jakob", "Klamm", 30)

        self.assertEqual(self.emp1.fullname, "Thomas Stoetzner")
        self.assertEqual(self.emp2.fullname, 'Jakob Klamm')

        self.emp1.first = "Juergen"
        self.emp2.first = "Werner"

        self.assertEqual(self.emp1.fullname, "Juergen Stoetzner")
        self.assertEqual(self.emp2.fullname, 'Werner Klamm')
コード例 #3
0
    def test_email(self):

        emp1 = Employee("Thomas", "Stoetzner", 5000)
        emp2 = Employee("Jakob", "Klamm", 30)

        self.assertEqual(emp1.email, "*****@*****.**")
        self.assertEqual(emp2.email, '*****@*****.**')

        emp1.first = "Juergen"
        emp2.first = "Werner"

        self.assertEqual(emp1.email, "*****@*****.**")
        self.assertEqual(emp2.email, '*****@*****.**')
コード例 #4
0
class TestEmployee(unittest.TestCase):

    @classmethod
    def setUpClass(cls):    #runs once before the whole test session
        print("setUpClass\n")

    @classmethod
    def tearDownClass(cls):
        print("\ntearDOwnClass")  #runs once after the whole test session


    def setUp(self): #runs before every single test
        print("setUp")
        self.emp1 = Employee("Thomas", "Stoetzner", 5000)
        self.emp2 = Employee("Jakob", "Klamm", 30)

    def tearDown(self): #runs after every single test
        print("tearDown")

    def test_email(self):
        self.assertEqual(self.emp1.email, "*****@*****.**")
        self.assertEqual(self.emp2.email, '*****@*****.**')

        self.emp1.first = "Juergen"
        self.emp2.first = "Werner"

        self.assertEqual(self.emp1.email, "*****@*****.**")
        self.assertEqual(self.emp2.email, '*****@*****.**')

    def test_fullname(self):

        self.emp1 = Employee("Thomas", "Stoetzner", 5000)
        self.emp2 = Employee("Jakob", "Klamm", 30)

        self.assertEqual(self.emp1.fullname, "Thomas Stoetzner")
        self.assertEqual(self.emp2.fullname, 'Jakob Klamm')

        self.emp1.first = "Juergen"
        self.emp2.first = "Werner"

        self.assertEqual(self.emp1.fullname, "Juergen Stoetzner")
        self.assertEqual(self.emp2.fullname, 'Werner Klamm')

    def test_apply_raise(self):
        self.emp1 = Employee("Thomas", "Stoetzner", 5000)
        self.emp2 = Employee("Jakob", "Klamm", 30)

        self.emp1.apply_raise()
        self.emp2.apply_raise()

        self.assertEqual(self.emp1.pay, 5250)
        self.assertEqual(self.emp2.pay, 31)

    def test_monthly_schedule(self):
        with patch("Logging.employee_root.requests.get") as mocked_get:
            mocked_get.return_value.ok = True
            mocked_get.return_value.text = "Success"

            schedule = self.emp1.monthly_schedule("May")
            mocked_get.assert_called_with("http://company.com/Stoetzner/May")
            self.assertEqual(schedule, "Success")

            mocked_get.return_value.ok = False

            schedule = self.emp1.monthly_schedule("June")
            mocked_get.assert_called_with("http://company.com/Stoetzner/June")
            self.assertEqual(schedule, "Bad response")
コード例 #5
0
 def setUp(self): #runs before every single test
     print("setUp")
     self.emp1 = Employee("Thomas", "Stoetzner", 5000)
     self.emp2 = Employee("Jakob", "Klamm", 30)