-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed a potential bug #337
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
57a3596
fixed a potential bug
wiseaidev 06d588a
add unit tests
wiseaidev 35696b6
remove unnecessary logic related to six module
wiseaidev 876e99a
remove six from dependencies
wiseaidev 635bab0
pass "ignore" as a kwarg
wiseaidev e7c0dba
get rid of try catch and simplify logic
wiseaidev da5f2f3
rm poetry.lock
wiseaidev 6785c8a
rm poetry.lock
wiseaidev 858d1ba
run black
wiseaidev 2434d6a
fix mypy issue
wiseaidev 87fc1f1
adjust other tests accordingly
wiseaidev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -43,6 +43,7 @@ class Order(BaseHashModel): | |
created_on: datetime.datetime | ||
|
||
class Member(BaseHashModel): | ||
id: int = Field(index=True) | ||
first_name: str = Field(index=True) | ||
last_name: str = Field(index=True) | ||
email: str = Field(index=True) | ||
|
@@ -64,6 +65,7 @@ class Meta: | |
@pytest_asyncio.fixture | ||
async def members(m): | ||
member1 = m.Member( | ||
id=0, | ||
first_name="Andrew", | ||
last_name="Brookins", | ||
email="[email protected]", | ||
|
@@ -73,6 +75,7 @@ async def members(m): | |
) | ||
|
||
member2 = m.Member( | ||
id=1, | ||
first_name="Kim", | ||
last_name="Brookins", | ||
email="[email protected]", | ||
|
@@ -82,6 +85,7 @@ async def members(m): | |
) | ||
|
||
member3 = m.Member( | ||
id=2, | ||
first_name="Andrew", | ||
last_name="Smith", | ||
email="[email protected]", | ||
|
@@ -129,6 +133,9 @@ async def test_exact_match_queries(members, m): | |
).all() | ||
assert actual == [member2] | ||
|
||
actual = await m.Member.find(m.Member.id == 0).all() | ||
assert actual == [member1] | ||
|
||
|
||
@py_test_mark_asyncio | ||
async def test_full_text_search_queries(members, m): | ||
|
@@ -176,6 +183,7 @@ async def test_tag_queries_boolean_logic(members, m): | |
@py_test_mark_asyncio | ||
async def test_tag_queries_punctuation(m): | ||
member1 = m.Member( | ||
id=0, | ||
first_name="Andrew, the Michael", | ||
last_name="St. Brookins-on-Pier", | ||
email="a|[email protected]", # NOTE: This string uses the TAG field separator. | ||
|
@@ -186,6 +194,7 @@ async def test_tag_queries_punctuation(m): | |
await member1.save() | ||
|
||
member2 = m.Member( | ||
id=1, | ||
first_name="Bob", | ||
last_name="the Villain", | ||
email="a|[email protected]", # NOTE: This string uses the TAG field separator. | ||
|
@@ -337,18 +346,19 @@ def test_validates_required_fields(m): | |
# Raises ValidationError: last_name is required | ||
# TODO: Test the error value | ||
with pytest.raises(ValidationError): | ||
m.Member(first_name="Andrew", zipcode="97086", join_date=today) | ||
m.Member(id=0, first_name="Andrew", zipcode="97086", join_date=today) | ||
|
||
|
||
def test_validates_field(m): | ||
# Raises ValidationError: join_date is not a date | ||
# TODO: Test the error value | ||
with pytest.raises(ValidationError): | ||
m.Member(first_name="Andrew", last_name="Brookins", join_date="yesterday") | ||
m.Member(id=0, first_name="Andrew", last_name="Brookins", join_date="yesterday") | ||
|
||
|
||
def test_validation_passes(m): | ||
member = m.Member( | ||
id=0, | ||
first_name="Andrew", | ||
last_name="Brookins", | ||
email="[email protected]", | ||
|
@@ -362,6 +372,7 @@ def test_validation_passes(m): | |
@py_test_mark_asyncio | ||
async def test_retrieve_first(m): | ||
member = m.Member( | ||
id=0, | ||
first_name="Simon", | ||
last_name="Prickett", | ||
email="[email protected]", | ||
|
@@ -373,6 +384,7 @@ async def test_retrieve_first(m): | |
await member.save() | ||
|
||
member2 = m.Member( | ||
id=1, | ||
first_name="Another", | ||
last_name="Member", | ||
email="[email protected]", | ||
|
@@ -384,6 +396,7 @@ async def test_retrieve_first(m): | |
await member2.save() | ||
|
||
member3 = m.Member( | ||
id=2, | ||
first_name="Third", | ||
last_name="Member", | ||
email="[email protected]", | ||
|
@@ -401,6 +414,7 @@ async def test_retrieve_first(m): | |
@py_test_mark_asyncio | ||
async def test_saves_model_and_creates_pk(m): | ||
member = m.Member( | ||
id=0, | ||
first_name="Andrew", | ||
last_name="Brookins", | ||
email="[email protected]", | ||
|
@@ -418,6 +432,7 @@ async def test_saves_model_and_creates_pk(m): | |
@py_test_mark_asyncio | ||
async def test_all_pks(m): | ||
member = m.Member( | ||
id=0, | ||
first_name="Simon", | ||
last_name="Prickett", | ||
email="[email protected]", | ||
|
@@ -429,6 +444,7 @@ async def test_all_pks(m): | |
await member.save() | ||
|
||
member1 = m.Member( | ||
id=1, | ||
first_name="Andrew", | ||
last_name="Brookins", | ||
email="[email protected]", | ||
|
@@ -449,6 +465,7 @@ async def test_all_pks(m): | |
@py_test_mark_asyncio | ||
async def test_delete(m): | ||
member = m.Member( | ||
id=0, | ||
first_name="Simon", | ||
last_name="Prickett", | ||
email="[email protected]", | ||
|
@@ -465,6 +482,7 @@ async def test_delete(m): | |
@py_test_mark_asyncio | ||
async def test_expire(m): | ||
member = m.Member( | ||
id=0, | ||
first_name="Expire", | ||
last_name="Test", | ||
email="[email protected]", | ||
|
@@ -529,6 +547,7 @@ class InvalidMember(m.BaseHashModel): | |
@py_test_mark_asyncio | ||
async def test_saves_many(m): | ||
member1 = m.Member( | ||
id=0, | ||
first_name="Andrew", | ||
last_name="Brookins", | ||
email="[email protected]", | ||
|
@@ -537,6 +556,7 @@ async def test_saves_many(m): | |
bio="This is the user bio.", | ||
) | ||
member2 = m.Member( | ||
id=1, | ||
first_name="Kim", | ||
last_name="Brookins", | ||
email="[email protected]", | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!