-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add read api calls + tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update ruff * update doc string * add start and end datetime filter * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix test --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
beca319
commit b598c29
Showing
2 changed files
with
41 additions
and
10 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
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 |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
get_api_requests_for_one_user, | ||
) | ||
|
||
from datetime import datetime, timedelta | ||
|
||
|
||
def test_get_user(db_session): | ||
db_session.add(UserSQL(email="[email protected]")) | ||
|
@@ -41,3 +43,23 @@ def test_get_api_requests_for_one_user(db_session): | |
requests_sql = get_api_requests_for_one_user(session=db_session, email=user.email) | ||
assert len(requests_sql) == 1 | ||
assert requests_sql[0].url == "test" | ||
|
||
|
||
def test_get_api_requests_for_one_user_start_datetime(db_session): | ||
user = get_user(session=db_session, email="[email protected]") | ||
db_session.add(APIRequestSQL(user_uuid=user.uuid, url="test")) | ||
|
||
requests_sql = get_api_requests_for_one_user( | ||
session=db_session, email=user.email, start_datetime=datetime.now() + timedelta(hours=1) | ||
) | ||
assert len(requests_sql) == 0 | ||
|
||
|
||
def test_get_api_requests_for_one_user_end_datetime(db_session): | ||
user = get_user(session=db_session, email="[email protected]") | ||
db_session.add(APIRequestSQL(user_uuid=user.uuid, url="test")) | ||
|
||
requests_sql = get_api_requests_for_one_user( | ||
session=db_session, email=user.email, end_datetime=datetime.now() - timedelta(hours=1) | ||
) | ||
assert len(requests_sql) == 0 |