Skip to content

Commit

Permalink
Remove artifact after unit test (#1589)
Browse files Browse the repository at this point in the history
  • Loading branch information
J535D165 committed Nov 19, 2023
1 parent 8743c1e commit b8f5167
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
19 changes: 9 additions & 10 deletions asreview/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def open_state(asreview_obj, review_id=None, read_only=True):
project.add_review(review_id)
else:
raise StateNotFoundError(
"State file does not exist, and in " "read only mode."
"State file does not exist, and in read only mode."
)
yield state
finally:
Expand Down Expand Up @@ -278,17 +278,16 @@ def config(self):
project_fp_lock = Path(self.project_path, PATH_PROJECT_CONFIG_LOCK)
lock = FileLock(project_fp_lock, timeout=3)

try:
with lock:
# read the file with project info
with open(project_fp, "r") as fp:
config = json.load(fp)
self._config = config
if not project_fp.exists():
raise ProjectNotFoundError(f"Project '{self.project_path}' not found")

return config
with lock:
# read the file with project info
with open(project_fp, "r") as fp:
config = json.load(fp)
self._config = config

except FileNotFoundError:
raise ProjectNotFoundError(f"Project '{self.project_path}' not found")
return config

@config.setter
def config(self, config):
Expand Down
8 changes: 6 additions & 2 deletions tests/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,15 @@ def test_init_project_already_exists(tmpdir):
ASReviewProject.create(project_path)


def test_invalid_project_folder():
def test_invalid_project_folder(tmpdir):
project_path = Path(tmpdir, "this_is_not_a_project")
with pytest.raises(StateNotFoundError):
with open_state("this_is_not_a_project") as state: # noqa
with open_state(project_path) as state: # noqa
pass

# there should be no folder called "this_is_not_a_project"
assert not Path(project_path).is_dir()


def test_state_not_found(tmpdir):
project_path = Path(tmpdir, "test.asreview")
Expand Down

0 comments on commit b8f5167

Please sign in to comment.