~suutari-olli/openlp/force-split

« back to all changes in this revision

Viewing changes to tests/functional/openlp_core_common/test_registry.py

  • Committer: suutari-olli
  • Date: 2016-06-16 19:01:36 UTC
  • mfrom: (2656.1.18 openlp)
  • Revision ID: suutari.olli@gmail.com-20160616190136-92zdww04ieout3ho
Merged trunk?

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
class TestRegistry(TestCase):
35
35
 
36
 
    def registry_service_test(self):
 
36
    def test_registry_service(self):
37
37
        """
38
38
        Test the registry creation and its usage
39
39
        """
59
59
        temp = Registry().get('test2')
60
60
        self.assertEqual(temp, None, 'None should have been returned for missing service')
61
61
 
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')
67
67
 
68
 
    def registry_function_test(self):
 
68
    def test_registry_function(self):
69
69
        """
70
70
        Test the registry function creation and their usages
71
71
        """
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')
95
95
 
96
 
    def remove_function_test(self):
 
96
    def test_registry_working_flags(self):
 
97
        """
 
98
        Test the registry working flags creation and its usage
 
99
        """
 
100
        # GIVEN: A new registry
 
101
        Registry.create()
 
102
 
 
103
        # WHEN: I add a working flag it should save it
 
104
        my_data = 'Lamas'
 
105
        my_data2 = 'More Lamas'
 
106
        Registry().set_flag('test1', my_data)
 
107
 
 
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')
 
111
 
 
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')
 
117
 
 
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')
 
124
 
 
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')
 
132
 
 
133
    def test_remove_function(self):
97
134
        """
98
135
        Test the remove_function() method
99
136
        """