-
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.
Merge pull request #13 from oribarilan/feature/at
Adding `at`
- Loading branch information
Showing
10 changed files
with
123 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import pytest | ||
|
||
from fliq import q | ||
from fliq.exceptions import ElementNotFoundException | ||
from fliq.tests.fliq_test_utils import Params | ||
|
||
|
||
class TestAt: | ||
@pytest.mark.parametrize(Params.sig_iterable, Params.iterable_empty()) | ||
def test_at_withDefault_hasNoItems(self, iter_type, iterable, iterable_list): | ||
assert q(iterable).at(0, default=None) is None | ||
|
||
@pytest.mark.parametrize(Params.sig_iterable, Params.iterable_empty()) | ||
def test_at_withoutDefault_hasNoItems(self, iter_type, iterable, iterable_list): | ||
with pytest.raises(ElementNotFoundException): | ||
assert q(iterable).at(0) | ||
|
||
@pytest.mark.parametrize(Params.sig_iterable, Params.iterable_single()) | ||
def test_at_withDefault_hasSingleItem(self, iter_type, iterable, iterable_list): | ||
assert q(iterable).at(0, default=None) == iterable_list[0] | ||
|
||
@pytest.mark.parametrize(Params.sig_iterable, Params.iterable_single()) | ||
def test_at_withDefault_hasSinlgeItem_indexIsTooBig(self, iter_type, iterable, iterable_list): | ||
assert q(iterable).at(1, default=None) is None | ||
|
||
@pytest.mark.parametrize(Params.sig_iterable, Params.iterable_empty()) | ||
def test_at_hasNoItems_raisesException(self, iter_type, iterable, iterable_list): | ||
with pytest.raises(ElementNotFoundException): | ||
q(iterable).at(0) | ||
|
||
@pytest.mark.parametrize(Params.sig_iterable, Params.iterable_multi()) | ||
def test_at_hasItems_indexTooBig_raisesException(self, iter_type, iterable, iterable_list): | ||
with pytest.raises(ElementNotFoundException): | ||
q(iterable).at(6) | ||
|
||
@pytest.mark.parametrize(Params.sig_iterable, Params.iterable_multi()) | ||
def test_at_hasNoItems(self, iter_type, iterable, iterable_list): | ||
assert q(iterable).at(3) == iterable_list[3] |
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