-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* TDD: add failing test * lint * fix by inserting using on_conflict_do_nothing
- Loading branch information
1 parent
92503cf
commit ceaec24
Showing
2 changed files
with
34 additions
and
19 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
from concurrent.futures import ThreadPoolExecutor | ||
from functools import partial | ||
|
||
from pvsite_datamodel import SiteGroupSQL, UserSQL | ||
from pvsite_datamodel.read import get_user_by_email | ||
from pvsite_datamodel.write.user_and_site import create_site_group, create_user | ||
|
@@ -36,3 +39,14 @@ def test_get_user_by_email_no_user_maker_user_false(self, db_session): | |
) | ||
assert user is None | ||
assert len(db_session.query(UserSQL).all()) == 0 | ||
|
||
def test_make_user_db_twice(self, db_session): | ||
get_user_by_email_partial = partial(get_user_by_email, db_session, "[email protected]") | ||
tasks = [get_user_by_email_partial for _ in range(5)] | ||
|
||
with ThreadPoolExecutor() as executor: | ||
running_tasks = [executor.submit(task) for task in tasks] | ||
for running_task in running_tasks: | ||
running_task.result() | ||
|
||
assert len(db_session.query(UserSQL).all()) == 1 |