-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test coverage to makefile command, start refactoring cache for si…
…ngle and multifile options
- Loading branch information
Showing
14 changed files
with
233 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[run] | ||
omit = tests/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ cache/* | |
.idea/* | ||
|
||
*DS_Store | ||
*__pycache__/* | ||
__pycache__/* | ||
*/__pycache__/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ install: | |
|
||
.PHONY: test | ||
test: | ||
pytest | ||
pytest --cov=./ --cov-config=.coveragerc | ||
|
||
.PHONY: lint | ||
lint: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
import json | ||
|
||
CACHE_LOCATION = "cache" | ||
|
||
|
||
class MultiFileCache: | ||
def __init__(self, location): | ||
self.location = location | ||
if not os.path.exists(location): | ||
with open(location, 'w') as file: | ||
json.dump({}, file) | ||
|
||
def add_to_cache(self, key, value): | ||
with open(self.location, 'r+') as file: | ||
cache = json.load(file) | ||
cache[key] = value | ||
file.seek(0) | ||
json.dump(cache, file) | ||
file.truncate() | ||
|
||
def retrieve_value(self, key): | ||
with open(self.location, 'r') as file: | ||
cache = json.load(file) | ||
result = cache.get(key) | ||
if result is not None: | ||
print(f"cache hit. key:{key}") | ||
return result | ||
|
||
def delete_cache(self): | ||
if os.path.exists(self.location): | ||
os.remove(self.location) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ requests | |
matplotlib | ||
argparse | ||
pytest | ||
pytest-cov | ||
ruff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Oops, something went wrong.