diff --git a/aggify/aggify.py b/aggify/aggify.py index be28cab..a5cca90 100644 --- a/aggify/aggify.py +++ b/aggify/aggify.py @@ -576,8 +576,6 @@ def lookup( expected_list=[["local_field", "foreign_field"], "let"] ) elif not let: - if not (local_field and foreign_field): - raise InvalidArgument(expected_list=["local_field", "foreign_field"]) lookup_stage = { "$lookup": { "from": from_collection_name, diff --git a/aggify/utilty.py b/aggify/utilty.py index 3b40994..ea056ce 100644 --- a/aggify/utilty.py +++ b/aggify/utilty.py @@ -6,17 +6,6 @@ from aggify.types import CollectionType -def int_to_slice(final_index: int) -> slice: - """ - Converts an integer to a slice, assuming that the start index is 0. - - Examples: - >>> int_to_slice(3) - slice(0, 2) - """ - return slice(0, final_index) - - def to_mongo_positive_index(index: Union[int, slice]) -> slice: if isinstance(index, int): if index < 0: diff --git a/tests/test_aggify.py b/tests/test_aggify.py index 57c5734..b894922 100644 --- a/tests/test_aggify.py +++ b/tests/test_aggify.py @@ -11,6 +11,7 @@ InvalidOperator, AlreadyExistsField, InvalidEmbeddedField, + MongoIndexError, ) @@ -597,3 +598,19 @@ def test_replace_base_invalid_embedded_field(self): aggify = Aggify(BaseModel) with pytest.raises(InvalidEmbeddedField): aggify._replace_base("name") + + def test_aggify_get_item_negative_index(self): + with pytest.raises(MongoIndexError): + var = Aggify(BaseModel).filter(name=1)[-1:1] + + def test_aggify_get_item_slice_step_not_none(self): + with pytest.raises(MongoIndexError): + var = Aggify(BaseModel).filter(name=1)[slice(1, 3, 2)] + + def test_aggify_get_item_slice_start_gte_stop(self): + with pytest.raises(MongoIndexError): + var = Aggify(BaseModel).filter(name=1)[slice(3, 1)] + + def test_aggify_get_item_slice_negative_start(self): + with pytest.raises(MongoIndexError): + var = Aggify(BaseModel).filter(name=1)[slice(-5, -1)]