59
59
temp = Registry().get('test2')
60
60
self.assertEqual(temp, None, 'None should have been returned for missing service')
62
# WHEN I try to replace a component I should be allowed (testing only)
62
# WHEN I try to replace a component I should be allowed
63
63
Registry().remove('test1')
64
64
# THEN I will get an exception
65
65
temp = Registry().get('test1')
66
66
self.assertEqual(temp, None, 'None should have been returned for deleted service')
68
def registry_function_test(self):
68
def test_registry_function(self):
70
70
Test the registry function creation and their usages
93
93
# THEN: I expect then function to have been called and a return given
94
94
self.assertEqual(return_value[0], 'function_2', 'A return value is provided and matches')
96
def remove_function_test(self):
96
def test_registry_working_flags(self):
98
Test the registry working flags creation and its usage
100
# GIVEN: A new registry
103
# WHEN: I add a working flag it should save it
105
my_data2 = 'More Lamas'
106
Registry().set_flag('test1', my_data)
108
# THEN: we should be able retrieve the saved component
109
temp = Registry().get_flag('test1')
110
self.assertEquals(temp, my_data, 'The value should have been saved')
112
# WHEN: I add a component for the second time I am not mad.
113
# THEN and I will not get an exception
114
Registry().set_flag('test1', my_data2)
115
temp = Registry().get_flag('test1')
116
self.assertEquals(temp, my_data2, 'The value should have been updated')
118
# WHEN I try to get back a non existent Working Flag
119
# THEN I will get an exception
120
with self.assertRaises(KeyError) as context1:
121
temp = Registry().get_flag('test2')
122
self.assertEqual(context1.exception.args[0], 'Working Flag test2 not found in list',
123
'KeyError exception should have been thrown for missing working flag')
125
# WHEN I try to replace a working flag I should be allowed
126
Registry().remove_flag('test1')
127
# THEN I will get an exception
128
with self.assertRaises(KeyError) as context:
129
temp = Registry().get_flag('test1')
130
self.assertEqual(context.exception.args[0], 'Working Flag test1 not found in list',
131
'KeyError exception should have been thrown for duplicate working flag')
133
def test_remove_function(self):
98
135
Test the remove_function() method