Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): query command builder (#3085)
- Loading branch information
Showing
3 changed files
with
64 additions
and
82 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,43 @@ | ||
from typing import Type | ||
|
||
import pytest | ||
|
||
from renku.command.command_builder import Command | ||
from renku.command.command_builder.database import DatabaseCommand | ||
from renku.command.command_builder.repo import Commit, Isolation, RequireClean | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input,cls,expected", | ||
[ | ||
(Command(), Command, True), | ||
(Command(), DatabaseCommand, False), | ||
(Command().with_git_isolation(), Isolation, True), | ||
(Command().with_git_isolation(), RequireClean, False), | ||
(Command().with_git_isolation().with_commit(), Command, True), | ||
(Command().with_git_isolation().with_commit(), Isolation, True), | ||
(Command().with_git_isolation().with_commit(), Commit, True), | ||
(Command().with_git_isolation().with_commit(), DatabaseCommand, False), | ||
(Command().with_git_isolation().with_commit().with_database(), DatabaseCommand, True), | ||
], | ||
) | ||
def test_any_builder_is_instance_of(input: Command, cls: Type, expected: bool): | ||
assert input.any_builder_is_instance_of(cls) == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input,expected", | ||
[ | ||
(Command(), False), | ||
(Command().with_git_isolation(), False), | ||
(Command().with_git_isolation().with_commit(), False), | ||
(Command().with_git_isolation().with_commit().with_database(write=True), True), | ||
(Command().with_git_isolation().with_commit().with_database(write=False), False), | ||
(Command().with_database(write=True), True), | ||
(Command().with_database(write=False), False), | ||
(Command().with_git_isolation().with_database(write=True).with_commit(), True), | ||
(Command().with_git_isolation().with_database(write=False).with_commit(), False), | ||
], | ||
) | ||
def test_will_write_to_database(input: Command, expected: bool): | ||
assert input.will_write_to_database == expected |