-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
147 lines (116 loc) · 4.28 KB
/
test.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
139
140
141
142
143
144
145
146
147
import unittest
from utils import *
class TestArguments(unittest.TestCase):
valid_workdir = "/Volumes/Samsung_T5/data/SO_archive_2019_12/"
def test_f_only(self):
args = [
"-f",
"Tags",
self.valid_workdir,
]
force_overwrite, progress_bar, filename, workdir, release = init_from_arguments(args)
self.assertEqual(force_overwrite, True)
self.assertEqual(progress_bar, False)
self.assertEqual(filename, "Tags")
self.assertEqual(workdir, self.valid_workdir)
self.assertEqual(release, None)
def test_force_only(self):
args = [
"--force",
"Tags",
self.valid_workdir,
]
force_overwrite, progress_bar, filename, workdir, release = init_from_arguments(args)
self.assertEqual(force_overwrite, True)
self.assertEqual(progress_bar, False)
self.assertEqual(filename, "Tags")
self.assertEqual(workdir, self.valid_workdir)
self.assertEqual(release, None)
def test_p_only(self):
args = [
"-p",
"Tags",
self.valid_workdir,
]
force_overwrite, progress_bar, filename, workdir, release = init_from_arguments(args)
self.assertEqual(force_overwrite, False)
self.assertEqual(progress_bar, True)
self.assertEqual(filename, "Tags")
self.assertEqual(workdir, self.valid_workdir)
self.assertEqual(release, None)
def test_progress_bar_only(self):
args = [
"--progress-bar",
"Tags",
self.valid_workdir,
]
force_overwrite, progress_bar, filename, workdir, release = init_from_arguments(args)
self.assertEqual(force_overwrite, False)
self.assertEqual(progress_bar, True)
self.assertEqual(filename, "Tags")
self.assertEqual(workdir, self.valid_workdir)
self.assertEqual(release, None)
def test_f_and_p(self):
args = [
"-f",
"-p",
"Tags",
self.valid_workdir,
]
force_overwrite, progress_bar, filename, workdir, release = init_from_arguments(args)
self.assertEqual(force_overwrite, True)
self.assertEqual(progress_bar, True)
self.assertEqual(filename, "Tags")
self.assertEqual(workdir, self.valid_workdir)
self.assertEqual(release, None)
def test_force_and_progress_bar(self):
args = [
"--force",
"--progress-bar",
"Tags",
self.valid_workdir,
]
force_overwrite, progress_bar, filename, workdir, release = init_from_arguments(args)
self.assertEqual(force_overwrite, True)
self.assertEqual(progress_bar, True)
self.assertEqual(filename, "Tags")
self.assertEqual(workdir, self.valid_workdir)
self.assertEqual(release, None)
def test_options_reverse_order(self):
args = [
"--progress-bar",
"--force",
"Tags",
self.valid_workdir,
]
force_overwrite, progress_bar, filename, workdir, release = init_from_arguments(args)
self.assertEqual(force_overwrite, True)
self.assertEqual(progress_bar, True)
self.assertEqual(filename, "Tags")
self.assertEqual(workdir, self.valid_workdir)
self.assertEqual(release, None)
def test_f_and_force(self):
args = [
"-f",
"--force",
"Tags",
self.valid_workdir,
]
force_overwrite, progress_bar, filename, workdir, release = init_from_arguments(args)
self.assertEqual(force_overwrite, True)
self.assertEqual(progress_bar, False)
self.assertEqual(filename, "Tags")
self.assertEqual(workdir, self.valid_workdir)
self.assertEqual(release, None)
def test_invalid_option(self):
args = [
"-f",
"-a",
"Tags",
self.valid_workdir,
]
with self.assertRaises(SystemExit) as cm:
force_overwrite, progress_bar, filename, workdir, release = init_from_arguments(args)
self.assertEqual(cm.exception.code, 1)
if __name__ == "__main__":
unittest.main()