generated from mlibrary/python-starter
-
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.
- Loading branch information
Showing
7 changed files
with
68 additions
and
5 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,26 @@ | ||
import typer | ||
from aim.hathifiles import poll | ||
from aim.services import S | ||
|
||
app = typer.Typer() | ||
|
||
|
||
@app.command() | ||
def create_store_file(): | ||
f""" | ||
Genereates a new store file at {S.hathifiles_store_path} if one does not | ||
already exist. The new file is based on the latest hathi_files_list.json | ||
from hathitrust.org | ||
""" | ||
poll.create_store_file() | ||
|
||
|
||
@app.command() | ||
def check_for_new_update_files(): | ||
""" | ||
Pulls the latest hathi_files_list.json from hathitrust.org and checks if | ||
there are any update files that aren't in the store. If there are new files | ||
it notifies the argo events webhook and replaces the store file with the old | ||
files and the new ones. | ||
""" | ||
poll.check_for_new_update_files() |
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
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,7 @@ | ||
aim.cli.hathifiles module | ||
========================= | ||
|
||
.. automodule:: aim.cli.hathifiles | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
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 |
---|---|---|
|
@@ -13,4 +13,5 @@ Submodules | |
:maxdepth: 4 | ||
|
||
aim.cli.digifeeds | ||
aim.cli.hathifiles | ||
aim.cli.main |
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,23 @@ | ||
from typer.testing import CliRunner | ||
from aim.cli.main import app | ||
from aim.hathifiles import poll | ||
|
||
runner = CliRunner() | ||
|
||
|
||
def test_hathifiles_create_store_file(mocker): | ||
create_store_file_mock = mocker.patch.object(poll, "create_store_file") | ||
|
||
result = runner.invoke(app, ["hathifiles", "create-store-file"]) | ||
|
||
assert result.exit_code == 0 | ||
assert create_store_file_mock.call_count == 1 | ||
|
||
|
||
def test_hathifiles_check_for_new_update_files(mocker): | ||
create_files_mock = mocker.patch.object(poll, "check_for_new_update_files") | ||
|
||
result = runner.invoke(app, ["hathifiles", "check-for-new-update-files"]) | ||
|
||
assert result.exit_code == 0 | ||
assert create_files_mock.call_count == 1 |
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