-
Notifications
You must be signed in to change notification settings - Fork 30
/
test_project.py
66 lines (56 loc) · 1.96 KB
/
test_project.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
"""
Tests for Project Commands
"""
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
# TODO: include builtin libraries for the appropriate Python
# try:
# import __builtin__
# except ImportError:
# # Python 3
# import builtins as __builtin__
import os
import tempfile
import platform
from datmo import __version__
from datmo.cli.driver.helper import Helper
from datmo.cli.parser import parser
from datmo.cli.command.project import ProjectCommand
class TestProject():
def setup_class(self):
# provide mountable tmp directory for docker
tempfile.tempdir = "/tmp" if not platform.system(
) == "Windows" else None
test_datmo_dir = os.environ.get('TEST_DATMO_DIR',
tempfile.gettempdir())
self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir)
self.cli_helper = Helper()
self.project = ProjectCommand(self.temp_dir, self.cli_helper, parser)
def teardown_class(self):
pass
def test_datmo_init(self):
self.project.parse(
["init", "--name", "foobar", "--description", "test model"])
self.project.execute()
# test for desired side effects
assert os.path.exists(os.path.join(self.temp_dir, '.datmo'))
def test_datmo_init_invalid_arg(self):
exception_thrown = False
try:
self.project.parse(["init", "--foobar", "foobar"])
except Exception:
exception_thrown = True
assert exception_thrown
def test_datmo_version(self):
self.project.parse(["version"])
result = self.project.execute()
# test for desired side effects
assert __version__ in result
def test_datmo_version_invalid_arg(self):
exception_thrown = False
try:
self.project.parse(["version", "--foobar"])
except Exception:
exception_thrown = True
assert exception_thrown