Code Duplication    Length = 22-22 lines in 3 locations

elodie/tests/plugins_test.py 3 locations

@@ 192-213 (lines=22) @@
189
    assert status_batch == False, status_batch
190
    assert status_before == False, status_before
191
192
@mock.patch('elodie.config.config_file', '%s/config.ini-throw-runtime-error' % gettempdir())
193
def test_throw_error_runtime_error():
194
    with open('%s/config.ini-throw-runtime-error' % gettempdir(), 'w') as f:
195
        f.write("""
196
[Plugins]
197
plugins=RuntimeError
198
        """)
199
    if hasattr(load_config, 'config'):
200
        del load_config.config
201
202
    plugins = Plugins()
203
    plugins.load()
204
    status_after = plugins.run_all_after('', '', '', '')
205
    status_batch = plugins.run_batch()
206
    status_before = plugins.run_all_before('', '')
207
208
    if hasattr(load_config, 'config'):
209
        del load_config.config
210
211
    assert status_after == True, status_after
212
    assert status_batch == True, status_batch
213
    assert status_before == True, status_before
214
215
def test_plugin_base_inherits_db():
216
    plugin_base = PluginBase()
@@ 169-190 (lines=22) @@
166
    assert status_batch == False, status_batch
167
    assert status_before == False, status_before
168
169
@mock.patch('elodie.config.config_file', '%s/config.ini-throw-error-one-of-many' % gettempdir())
170
def test_throw_error_one_of_many():
171
    with open('%s/config.ini-throw-error-one-of-many' % gettempdir(), 'w') as f:
172
        f.write("""
173
[Plugins]
174
plugins=Dummy,ThrowError
175
        """)
176
    if hasattr(load_config, 'config'):
177
        del load_config.config
178
179
    plugins = Plugins()
180
    plugins.load()
181
    status_after = plugins.run_all_after('', '', '', '')
182
    status_batch = plugins.run_batch()
183
    status_before = plugins.run_all_before('', '')
184
185
    if hasattr(load_config, 'config'):
186
        del load_config.config
187
188
    assert status_after == False, status_after
189
    assert status_batch == False, status_batch
190
    assert status_before == False, status_before
191
192
@mock.patch('elodie.config.config_file', '%s/config.ini-throw-runtime-error' % gettempdir())
193
def test_throw_error_runtime_error():
@@ 146-167 (lines=22) @@
143
    assert before_ran_1 == False, before_ran_1
144
    assert before_ran_2 == True, before_ran_2
145
146
@mock.patch('elodie.config.config_file', '%s/config.ini-throw-error' % gettempdir())
147
def test_throw_error():
148
    with open('%s/config.ini-throw-error' % gettempdir(), 'w') as f:
149
        f.write("""
150
[Plugins]
151
plugins=ThrowError
152
        """)
153
    if hasattr(load_config, 'config'):
154
        del load_config.config
155
156
    plugins = Plugins()
157
    plugins.load()
158
    status_after = plugins.run_all_after('', '', '', '')
159
    status_batch = plugins.run_batch()
160
    status_before = plugins.run_all_before('', '')
161
162
    if hasattr(load_config, 'config'):
163
        del load_config.config
164
165
    assert status_after == False, status_after
166
    assert status_batch == False, status_batch
167
    assert status_before == False, status_before
168
169
@mock.patch('elodie.config.config_file', '%s/config.ini-throw-error-one-of-many' % gettempdir())
170
def test_throw_error_one_of_many():