Skip to content

Commit

Permalink
error with InvalidProjectPathException rather than create path. fix i…
Browse files Browse the repository at this point in the history
…ssue #1
  • Loading branch information
asampat3090 committed Apr 23, 2018
1 parent ef34c9d commit 284a5be
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
9 changes: 4 additions & 5 deletions datmo/core/controller/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,17 @@ class BaseController(object):
Return the config dictionary based on key
get_config_defaults()
Return the configuration defaults
"""

def __init__(self, home):
self.home = home
if not os.path.isdir(self.home):
raise InvalidProjectPathException(__("error",
"controller.base.__init__",
home))
self.config = JSONStore(os.path.join(self.home,
".datmo",
".config"))
if not os.path.isdir(self.home):
raise InvalidProjectPathException(__("error",
"controller.base.__init__",
home))
# property caches and initial values
self._dal = None
self._model = None
Expand Down
4 changes: 2 additions & 2 deletions datmo/core/controller/code/driver/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def __init__(self, filepath, execpath, remote_url=None):
# Check if filepath exists
if not os.path.exists(self.filepath):
raise DoesNotExistException(__("error",
"controller.code.driver.git.__init__.dne",
filepath))
"controller.code.driver.git.__init__.dne",
filepath))
self.execpath = execpath
# Check the execpath and the version
try:
Expand Down
4 changes: 2 additions & 2 deletions datmo/core/controller/file/driver/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def __init__(self, filepath):
# Check if filepath exists
if not os.path.exists(self.filepath):
raise DoesNotExistException(__("error",
"controller.file.driver.local.__init__",
filepath))
"controller.file.driver.local.__init__",
filepath))
self._is_initialized = self.is_initialized
self.type = "local"

Expand Down
12 changes: 10 additions & 2 deletions datmo/core/controller/test/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from datmo.core.controller.base import BaseController
from datmo.core.controller.code.driver.git import GitCodeDriver
from datmo.core.util.exceptions import \
DatmoModelNotInitializedException
DatmoModelNotInitializedException, InvalidProjectPathException


class TestBaseController():
Expand All @@ -21,11 +21,19 @@ def setup_method(self):
test_datmo_dir = os.environ.get('TEST_DATMO_DIR',
tempfile.gettempdir())
self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir)
self.base = BaseController(self.temp_dir)
self.base = BaseController(home=self.temp_dir)

def teardown_method(self):
shutil.rmtree(self.temp_dir)

def test_failed_controller_instantiation(self):
failed = False
try:
BaseController(home=os.path.join("does", "not", "exist"))
except InvalidProjectPathException:
failed = True
assert failed

def test_instantiation(self):
assert self.base != None

Expand Down
6 changes: 3 additions & 3 deletions datmo/test/test_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from datmo.snapshot import create, ls
from datmo.core.controller.project import ProjectController
from datmo.core.util.exceptions import GitCommitDoesNotExist, \
ProjectNotInitializedException, SessionDoesNotExistException
InvalidProjectPathException, SessionDoesNotExistException


class TestSnapshotModule():
Expand All @@ -30,7 +30,7 @@ def test_create(self):
try:
create(message="test",
home=os.path.join("does","not", "exist"))
except ProjectNotInitializedException:
except InvalidProjectPathException:
failed = True
assert failed

Expand Down Expand Up @@ -79,7 +79,7 @@ def test_ls(self):
failed = False
try:
ls(home=os.path.join("does","not", "exist"))
except ProjectNotInitializedException:
except InvalidProjectPathException:
failed = True
assert failed

Expand Down

0 comments on commit 284a5be

Please sign in to comment.