diff --git a/behavioral/catalog.py b/behavioral/catalog.py index 09a6f26c..342c7cc2 100644 --- a/behavioral/catalog.py +++ b/behavioral/catalog.py @@ -168,6 +168,7 @@ def main(): test.main_method() if __name__ == "__main__": + main() ### OUTPUT ### diff --git a/dft/constructor_injection.py b/dft/constructor_injection.py index 79596b05..cb061fa8 100644 --- a/dft/constructor_injection.py +++ b/dft/constructor_injection.py @@ -20,6 +20,7 @@ def get_current_time_as_html_fragment(self): return current_time_as_html_fragment """ + class TimeDisplay(object): def __init__(self, time_provider): @@ -30,6 +31,7 @@ def get_current_time_as_html_fragment(self): current_time_as_html_fragment = "{}".format(current_time) return current_time_as_html_fragment + class ProductionCodeTimeProvider(object): """ Production code version of the time provider (just a wrapper for formatting @@ -38,9 +40,11 @@ class ProductionCodeTimeProvider(object): def now(self): current_time = datetime.datetime.now() - current_time_formatted = "{}:{}".format(current_time.hour, current_time.minute) + current_time_formatted = "{}:{}".format(current_time.hour, + current_time.minute) return current_time_formatted + class MidnightTimeProvider(object): """ Class implemented as hard-coded stub (in contrast to configurable stub). diff --git a/dft/setter_injection.py b/dft/setter_injection.py index c7da09ad..a8f6e272 100644 --- a/dft/setter_injection.py +++ b/dft/setter_injection.py @@ -21,6 +21,7 @@ def get_current_time_as_html_fragment(self): return current_time_as_html_fragment """ + class TimeDisplay(object): def __init__(self): @@ -34,6 +35,7 @@ def get_current_time_as_html_fragment(self): current_time_as_html_fragment = "{}".format(current_time) return current_time_as_html_fragment + class ProductionCodeTimeProvider(object): """ Production code version of the time provider (just a wrapper for formatting @@ -42,9 +44,11 @@ class ProductionCodeTimeProvider(object): def now(self): current_time = datetime.datetime.now() - current_time_formatted = "{}:{}".format(current_time.hour, current_time.minute) + current_time_formatted = "{}:{}".format(current_time.hour, + current_time.minute) return current_time_formatted + class MidnightTimeProvider(object): """ Class implemented as hard-coded stub (in contrast to configurable stub). diff --git a/structural/adapter.py b/structural/adapter.py index b0bc1f23..0a00758c 100644 --- a/structural/adapter.py +++ b/structural/adapter.py @@ -5,6 +5,7 @@ class Dog(object): + def __init__(self): self.name = "Dog" @@ -13,6 +14,7 @@ def bark(self): class Cat(object): + def __init__(self): self.name = "Cat" @@ -21,6 +23,7 @@ def meow(self): class Human(object): + def __init__(self): self.name = "Human" @@ -29,6 +32,7 @@ def speak(self): class Car(object): + def __init__(self): self.name = "Car" @@ -74,12 +78,13 @@ def __init__(self, obj, **adapted_methods): def __getattr__(self, attr): """All non-adapted calls are passed to the object""" return getattr(self.obj, attr) - + def original_dict(self): """Print original object dict""" return self.obj.__dict__ def main(): + objects = [] dog = Dog() print(dog.__dict__) diff --git a/structural/front_controller.py b/structural/front_controller.py index e6a4939d..20de07af 100644 --- a/structural/front_controller.py +++ b/structural/front_controller.py @@ -9,16 +9,19 @@ class MobileView(object): + def show_index_page(self): print('Displaying mobile index page') class TabletView(object): + def show_index_page(self): print('Displaying tablet index page') class Dispatcher(object): + def __init__(self): self.mobile_view = MobileView() self.tablet_view = TabletView() @@ -34,6 +37,7 @@ def dispatch(self, request): class RequestController(object): """ front controller """ + def __init__(self): self.dispatcher = Dispatcher() @@ -72,4 +76,4 @@ def __init__(self, request): # Displaying mobile index page # Displaying tablet index page # cant dispatch the request -# request must be a Request object \ No newline at end of file +# request must be a Request object diff --git a/tests/test_decorator.py b/tests/test_decorator.py index 9f43e5b8..cc8938f5 100644 --- a/tests/test_decorator.py +++ b/tests/test_decorator.py @@ -21,4 +21,3 @@ def test_mixed_bold_and_italic(self): self.assertEqual( BoldWrapper(ItalicWrapper(self.raw_string)).render(), 'raw but not cruel') - diff --git a/tests/test_hsm.py b/tests/test_hsm.py index 6815c90e..e5b2f88f 100644 --- a/tests/test_hsm.py +++ b/tests/test_hsm.py @@ -57,10 +57,14 @@ def test_given_standby_on_message_switchover_shall_set_active(cls): cls.assertEqual(isinstance(cls.hsm._current_state, Active), True) def test_given_standby_on_message_switchover_shall_call_hsm_methods(cls): - with patch.object(cls.hsm, '_perform_switchover') as mock_perform_switchover,\ - patch.object(cls.hsm, '_check_mate_status') as mock_check_mate_status,\ - patch.object(cls.hsm, '_send_switchover_response') as mock_send_switchover_response,\ - patch.object(cls.hsm, '_next_state') as mock_next_state: + with patch.object(cls.hsm, + '_perform_switchover') as mock_perform_switchover,\ + patch.object(cls.hsm, + '_check_mate_status') as mock_check_mate_status,\ + patch.object(cls.hsm, + '_send_switchover_response') as mock_send_switchover_response,\ + patch.object(cls.hsm, + '_next_state') as mock_next_state: cls.hsm.on_message('switchover') cls.assertEqual(mock_perform_switchover.call_count, 1) cls.assertEqual(mock_check_mate_status.call_count, 1) diff --git a/tests/test_prototype.py b/tests/test_prototype.py index 4b896154..0ad94282 100644 --- a/tests/test_prototype.py +++ b/tests/test_prototype.py @@ -49,4 +49,3 @@ def test_particular_properties_retrieving(self): def test_extended_properties_retrieving(self): self.assertEqual(self.dispatcher.get_objects()['A'].ext_value, 'E') self.assertTrue(self.dispatcher.get_objects()['B'].diff) -