-
-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #218 from paul-finary/feature/skip_actions
Feature/skip actions
- Loading branch information
Showing
12 changed files
with
157 additions
and
21 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
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
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
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 |
---|---|---|
@@ -1,23 +1,65 @@ | ||
import pytest | ||
|
||
from beanie import Before, After | ||
|
||
from tests.odm.models import DocumentWithActions, InheritedDocumentWithActions | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"doc_class", [DocumentWithActions, InheritedDocumentWithActions] | ||
) | ||
async def test_actions_insert_replace(doc_class): | ||
test_name = "test_name" | ||
async def test_actions_insert(doc_class): | ||
test_name = f"test_actions_insert_{doc_class}" | ||
sample = doc_class(name=test_name) | ||
|
||
# TEST INSERT | ||
await sample.insert() | ||
assert sample.name != test_name | ||
assert sample.name == test_name.capitalize() | ||
assert sample.num_1 == 1 | ||
assert sample.num_2 == 9 | ||
|
||
# TEST REPLACE | ||
|
||
@pytest.mark.parametrize( | ||
"doc_class", [DocumentWithActions, InheritedDocumentWithActions] | ||
) | ||
async def test_actions_replace(doc_class): | ||
test_name = f"test_actions_replace_{doc_class}" | ||
sample = doc_class(name=test_name) | ||
|
||
await sample.insert() | ||
|
||
await sample.replace() | ||
assert sample.num_1 == 2 | ||
assert sample.num_3 == 99 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"doc_class", [DocumentWithActions, InheritedDocumentWithActions] | ||
) | ||
async def test_skip_actions_insert(doc_class): | ||
test_name = f"test_skip_actions_insert_{doc_class}" | ||
sample = doc_class(name=test_name) | ||
|
||
await sample.insert(skip_actions=[After, 'capitalize_name']) | ||
# capitalize_name has been skipped | ||
assert sample.name == test_name | ||
# add_one has not been skipped | ||
assert sample.num_1 == 1 | ||
# num_2_change has been skipped | ||
assert sample.num_2 == 10 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"doc_class", [DocumentWithActions, InheritedDocumentWithActions] | ||
) | ||
async def test_skip_actions_replace(doc_class): | ||
test_name = f"test_skip_actions_replace{doc_class}" | ||
sample = doc_class(name=test_name) | ||
|
||
await sample.insert() | ||
|
||
await sample.replace(skip_actions=[Before, 'num_3_change']) | ||
# add_one has been skipped | ||
assert sample.num_1 == 1 | ||
# num_3_change has been skipped | ||
assert sample.num_3 == 100 |
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,4 @@ | |
|
||
|
||
def test_version(): | ||
assert __version__ == "1.10.0" | ||
assert __version__ == "1.10.1" |