Skip to content

Commit 2785223

Browse files
committed
little cleanup
1 parent 793b299 commit 2785223

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/gaiaflow/managers/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def gaiaflow_path_exists_in_state(gaiaflow_path: Path, check_fs: bool = True) ->
175175

176176
def delete_project_state(gaiaflow_path: Path):
177177
state_file = get_state_file()
178-
log_info("state_file: " + str(state_file))
178+
log_info("found gaiaflow state file: " + str(state_file))
179179
if not state_file.exists():
180180
log_error(
181181
"State file not found at ~/.gaiaflow/state.json. Please run the services."
@@ -186,13 +186,14 @@ def delete_project_state(gaiaflow_path: Path):
186186
with open(state_file, "r") as f:
187187
state = json.load(f)
188188

189-
log_info("found! " + str(state.get("gaiaflow_path")) + str(state))
189+
assert isinstance(state, dict)
190+
190191
key = str(gaiaflow_path)
191192
if key in state:
192193
del state[key]
193194
with open(state_file, "w") as f:
194195
json.dump(state, f, indent=2)
195-
except (json.JSONDecodeError, FileNotFoundError, AttributeError, Exception):
196+
except (json.JSONDecodeError, FileNotFoundError, AssertionError, Exception):
196197
raise
197198

198199

tests/managers/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,13 @@ def test_state_file_missing(self):
203203
self.assertFalse(self.state_file.exists())
204204

205205
def test_delete_raises_jsondecodeerror(self):
206-
self.state_file.write_text("{ invalid_data }")
206+
self.state_file.write_text("{ invalid_data: '1' }")
207207
with self.assertRaises(json.JSONDecodeError):
208208
utils.delete_project_state(self.gaiaflow_path)
209209

210210
def test_delete_raises_when_state_is_string(self):
211211
self.state_file.write_text(json.dumps("invalid_data"))
212-
with self.assertRaises(AttributeError):
212+
with self.assertRaises(AssertionError):
213213
utils.delete_project_state(self.gaiaflow_path)
214214

215215
def test_update_project_state(self):

0 commit comments

Comments
 (0)