Code Duplication    Length = 19-19 lines in 3 locations

elodie/tests/filesystem_test.py 3 locations

@@ 282-300 (lines=19) @@
279
280
    assert file_name == helper.path_tz_fix('2015-12-05-with-title-some-title.jpg'), file_name
281
282
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom-with-empty-value' % gettempdir())
283
def test_get_file_name_custom_with_empty_value():
284
    with open('%s/config.ini-filename-custom-with-empty-value' % gettempdir(), 'w') as f:
285
        f.write("""
286
[File]
287
date=%Y-%m-%d
288
name=%date-%original_name-%title.%extension
289
        """)
290
    if hasattr(load_config, 'config'):
291
        del load_config.config
292
293
    filesystem = FileSystem()
294
    media = Photo(helper.get_file('plain.jpg'))
295
    file_name = filesystem.get_file_name(media)
296
297
    if hasattr(load_config, 'config'):
298
        del load_config.config
299
300
    assert file_name == helper.path_tz_fix('2015-12-05-plain.jpg'), file_name
301
302
def test_get_folder_path_plain():
303
    filesystem = FileSystem()
@@ 262-280 (lines=19) @@
259
260
    assert file_name == helper.path_tz_fix('2015-12-dec-plain.jpg'), file_name
261
262
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom-with-title' % gettempdir())
263
def test_get_file_name_custom_with_title():
264
    with open('%s/config.ini-filename-custom-with-title' % gettempdir(), 'w') as f:
265
        f.write("""
266
[File]
267
date=%Y-%m-%d
268
name=%date-%original_name-%title.%extension
269
        """)
270
    if hasattr(load_config, 'config'):
271
        del load_config.config
272
273
    filesystem = FileSystem()
274
    media = Photo(helper.get_file('with-title.jpg'))
275
    file_name = filesystem.get_file_name(media)
276
277
    if hasattr(load_config, 'config'):
278
        del load_config.config
279
280
    assert file_name == helper.path_tz_fix('2015-12-05-with-title-some-title.jpg'), file_name
281
282
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom-with-empty-value' % gettempdir())
283
def test_get_file_name_custom_with_empty_value():
@@ 242-260 (lines=19) @@
239
240
    assert file_name == helper.path_tz_fix('2015-12-05_00-59-26-plain-with-spaces-and-uppercase-123.jpg'), file_name
241
242
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom' % gettempdir())
243
def test_get_file_name_custom():
244
    with open('%s/config.ini-filename-custom' % gettempdir(), 'w') as f:
245
        f.write("""
246
[File]
247
date=%Y-%m-%b
248
name=%date-%original_name.%extension
249
        """)
250
    if hasattr(load_config, 'config'):
251
        del load_config.config
252
253
    filesystem = FileSystem()
254
    media = Photo(helper.get_file('plain.jpg'))
255
    file_name = filesystem.get_file_name(media)
256
257
    if hasattr(load_config, 'config'):
258
        del load_config.config
259
260
    assert file_name == helper.path_tz_fix('2015-12-dec-plain.jpg'), file_name
261
262
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom-with-title' % gettempdir())
263
def test_get_file_name_custom_with_title():