/
test_configfunctional.py
139 lines (100 loc) · 3.05 KB
/
test_configfunctional.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/env python
#encoding:utf-8
#author:dbr/Ben
#project:tvnamer
#repository:http://github.com/dbr/tvnamer
#license:Creative Commons GNU GPL v2
# http://creativecommons.org/licenses/GPL/2.0/
"""Tests various configs load correctly
"""
from functional_runner import run_tvnamer, verify_out_data
from nose.plugins.attrib import attr
@attr("functional")
def test_batchconfig():
"""Test configured batch mode works
"""
conf = """
{"always_rename": true,
"select_first": true}
"""
out_data = run_tvnamer(
with_files = ['scrubs.s01e01.avi'],
with_config = conf,
with_input = "")
expected_files = ['Scrubs - [01x01] - My First Day.avi']
verify_out_data(out_data, expected_files)
@attr("functional")
def test_skip_file_on_error():
"""Test the "skip file on error" config option works
"""
conf = """
{"skip_file_on_error": true,
"always_rename": true}
"""
out_data = run_tvnamer(
with_files = ['a.fake.episode.s01e01.avi'],
with_config = conf,
with_input = "")
expected_files = ['a.fake.episode.s01e01.avi']
verify_out_data(out_data, expected_files)
@attr("functional")
def test_do_not_skip_file_on_error():
"""Test setting "skip file on error" config option to False
"""
conf = """
{"skip_file_on_error": false,
"always_rename": true}
"""
out_data = run_tvnamer(
with_files = ['a.fake.episode.s01e01.avi'],
with_config = conf,
with_input = "")
expected_files = ['a fake episode - [01x01].avi']
verify_out_data(out_data, expected_files)
@attr("functional")
def test_lowercase_names():
"""Test setting "lowercase_filename" config option
"""
conf = """
{"lowercase_filename": true,
"always_rename": true,
"select_first": true}
"""
out_data = run_tvnamer(
with_files = ['scrubs.s01e01.avi'],
with_config = conf,
with_input = "")
expected_files = ['scrubs - [01x01] - my first day.avi']
verify_out_data(out_data, expected_files)
@attr("functional")
def test_lowercase_names():
"""Test custom blacklist to replace " " with "_"
"""
conf = """
{"custom_filename_character_blacklist": " ",
"replace_blacklisted_characters_with": "_",
"always_rename": true,
"select_first": true}
"""
out_data = run_tvnamer(
with_files = ['scrubs.s01e01.avi'],
with_config = conf,
with_input = "")
expected_files = ['Scrubs_-_[01x01]_-_My_First_Day.avi']
verify_out_data(out_data, expected_files)
@attr("functional")
def test_abs_epnmber():
"""Ensure the absolute episode number is available for custom
filenames in config
"""
conf = """
{"filename_with_episode": "%(seriesname)s - %(absoluteepisode)s%(ext)s",
"always_rename": true,
"select_first": true}
"""
out_data = run_tvnamer(
with_files = ['scrubs.s01e01.avi'],
with_config = conf,
with_input = "")
expected_files = ['Scrubs - 01.avi']
verify_out_data(out_data, expected_files)