Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions behavioral/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def main():
test.main_method()

if __name__ == "__main__":

main()

### OUTPUT ###
Expand Down
6 changes: 5 additions & 1 deletion dft/constructor_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -30,6 +31,7 @@ def get_current_time_as_html_fragment(self):
current_time_as_html_fragment = "<span class=\"tinyBoldText\">{}</span>".format(current_time)
return current_time_as_html_fragment


class ProductionCodeTimeProvider(object):
"""
Production code version of the time provider (just a wrapper for formatting
Expand All @@ -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).
Expand Down
6 changes: 5 additions & 1 deletion dft/setter_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def get_current_time_as_html_fragment(self):
return current_time_as_html_fragment
"""


class TimeDisplay(object):

def __init__(self):
Expand All @@ -34,6 +35,7 @@ def get_current_time_as_html_fragment(self):
current_time_as_html_fragment = "<span class=\"tinyBoldText\">{}</span>".format(current_time)
return current_time_as_html_fragment


class ProductionCodeTimeProvider(object):
"""
Production code version of the time provider (just a wrapper for formatting
Expand All @@ -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).
Expand Down
7 changes: 6 additions & 1 deletion structural/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


class Dog(object):

def __init__(self):
self.name = "Dog"

Expand All @@ -13,6 +14,7 @@ def bark(self):


class Cat(object):

def __init__(self):
self.name = "Cat"

Expand All @@ -21,6 +23,7 @@ def meow(self):


class Human(object):

def __init__(self):
self.name = "Human"

Expand All @@ -29,6 +32,7 @@ def speak(self):


class Car(object):

def __init__(self):
self.name = "Car"

Expand Down Expand Up @@ -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__)
Expand Down
6 changes: 5 additions & 1 deletion structural/front_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -34,6 +37,7 @@ def dispatch(self, request):

class RequestController(object):
""" front controller """

def __init__(self):
self.dispatcher = Dispatcher()

Expand Down Expand Up @@ -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
# request must be a Request object
1 change: 0 additions & 1 deletion tests/test_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ def test_mixed_bold_and_italic(self):
self.assertEqual(
BoldWrapper(ItalicWrapper(self.raw_string)).render(),
'<b><i>raw but not cruel</i></b>')

12 changes: 8 additions & 4 deletions tests/test_hsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion tests/test_prototype.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)