class TestSystem(unittest.TestCase):
    def setUp(self):
        self.authorizer = AuthorizerFake()
        self.system = System(self.authorizer)
        ...

    def test_schedule_appointment_for_bob(self):
        self.system.schedule_appointment(self.request)
        ...
예제 #2
0
class TestSystem2(unittest.TestCase):
    def setUp(self):
        self.authorizer = Mock(return_value=True)
        self.system = System(self.authorizer)
        self.request = Mock(username='******', password='******')

    def test_successful_schedule_appointment(self):
        self.system.schedule_appointment(self.request)
        self.assertTrue(self.authorizer.authorize.called)
        ...
예제 #3
0
class TestSystem(unittest.TestCase):
    def setUp(self):
        self.authorizer = AuthorizerSpy()
        self.system = System(self.authorizer)
        ...

    def test_schedule_appointment(self):
        self.system.schedule_appointment(self.request)
        self.assertTrue(self.authorizer.authorized_was_called)
        ...
예제 #4
0
class TestSystem(unittest.TestCase):
    def setUp(self):
        self.authorizer = Mock()
        self.system = System(self.authorizer)
        self.request = ...

    def test_schedule_appointment(self):
        self.authorizer.configure_mock(...)
        self.system.schedule_appointment(self.request)
        ...
class TestSystem2(unittest.TestCase):
    def setUp(self):
        self.authorizer = Mock()
        self.system = System(self.authorizer)
        self.request = Mock(username='******', password='******')

    def test_schedule_appointment_for_bob(self):
        self.authorizer.side_effect = \
            lambda username, password: username == 'Bob'
        self.system.schedule_appointment(self.request)
        ...