This repository has been archived by the owner on Apr 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tests] Refactored tests with Pytest.
- Loading branch information
ducdetronquito
committed
Dec 29, 2016
1 parent
24033ba
commit ccf3ad9
Showing
13 changed files
with
308 additions
and
360 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
__pycache__/* | ||
plume.egg-info/* | ||
.cache/* | ||
*.pyc | ||
*.db |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import plume | ||
from tests.utils import Pokemon | ||
|
||
import pytest | ||
|
||
|
||
class TestClause: | ||
|
||
def test_allows_or_operator_between_two_clauses(self): | ||
result = str((Pokemon.name == 'Charamander') | (Pokemon.name == 'Bulbasaur')) | ||
expected = "( name = 'Charamander' OR name = 'Bulbasaur' )" | ||
assert result == expected | ||
|
||
def test_or_operator_between_two_clauses_add_brackets(self): | ||
result = str((Pokemon.name == 'Charamander') | (Pokemon.name == 'Bulbasaur')) | ||
expected_open_bracket = '(' | ||
expected_close_bracket = ')' | ||
assert result[0] == expected_open_bracket | ||
assert result[-1] == expected_close_bracket | ||
|
||
def test_allows_and_operator_between_two_clauses(self): | ||
result = str((Pokemon.name == 'Charamander') & (Pokemon.level == 18)) | ||
expected = "name = 'Charamander' AND level = 18" | ||
assert result == expected | ||
|
||
def test_and_operator_between_two_clauses_does_not_add_brackets(self): | ||
result = str((Pokemon.name == 'Charamander') & (Pokemon.level == 18)) | ||
assert result[0] != '(' | ||
assert result[-1] != ')' | ||
|
||
def test_or_operator_has_lower_precedence_than_and_operator(self): | ||
result = str( | ||
(Pokemon.name == 'Charamander') | (Pokemon.name == 'Bulbasaur') | ||
& (Pokemon.level > 18) | ||
) | ||
expected = "( name = 'Charamander' OR name = 'Bulbasaur' AND level > 18 )" | ||
assert result == expected | ||
|
||
def test_bracket_has_higher_precedence_than_and_operator(self): | ||
result = str( | ||
((Pokemon.name == 'Charamander') | (Pokemon.name == 'Bulbasaur')) | ||
& (Pokemon.level > 18) | ||
) | ||
expected = "level > 18 AND ( name = 'Charamander' OR name = 'Bulbasaur' )" | ||
assert result == expected |
Oops, something went wrong.