forked from OpenBazaar/OpenBazaar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_migrations_util.py
40 lines (30 loc) · 1.03 KB
/
test_migrations_util.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
import unittest
from db.migrations import migrations_util
class TestMigrationUtil(unittest.TestCase):
"""Test the CLI API."""
@classmethod
def setUpClass(cls):
cls.db_path = '/some/random/path/file.db'
def setUp(self):
self.parser = migrations_util.make_argument_parser(self.db_path)
def test_cli_parser_default(self):
options = self.parser.parse_args(['upgrade'])
self.assertEqual(options.path, self.db_path)
self.assertEqual(options.action, 'upgrade')
def test_cli_parser_user(self):
other_db_path = '/some/other/path/file.db'
options = self.parser.parse_args([
'downgrade',
'--path',
other_db_path
])
self.assertEqual(options.path, other_db_path)
self.assertEqual(options.action, 'downgrade')
def test_cli_parser_bad_action(self):
self.assertRaises(
SystemExit,
self.parser.parse_args,
['retrograde']
)
if __name__ == '__main__':
unittest.main()