-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(issue-search): support IN for semver release search
- Loading branch information
Showing
3 changed files
with
60 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,6 +261,13 @@ def test(self): | |
self.run_test("<=", "1.2.3", "IN", [release.version]) | ||
self.run_test("=", "1.2.4", "IN", [release_2.version]) | ||
|
||
def test_semver_in_operator(self): | ||
release = self.create_release(version="[email protected]") | ||
release_2 = self.create_release(version="[email protected]") | ||
self.run_test("IN", ["1.2.3", "1.2.4"], "IN", [release.version, release_2.version]) | ||
# TODO: support not in operator | ||
# self.run_test("NOT IN", ["1.2.3", "1.2.4"], "NOT IN", [release.version, release_2.version]) | ||
|
||
def test_invert_query(self): | ||
# Tests that flipping the query works and uses a NOT IN. Test all operators to | ||
# make sure the inversion works correctly. | ||
|
@@ -436,12 +443,6 @@ def test_invalid_params(self): | |
with pytest.raises(ValueError, match="organization_id is a required param"): | ||
_semver_filter_converter(filter, key, {"something": 1}) | ||
|
||
filter = SearchFilter(SearchKey(key), "IN", SearchValue("sentry")) | ||
with pytest.raises( | ||
InvalidSearchQuery, match="Invalid operation 'IN' for semantic version filter." | ||
): | ||
_semver_filter_converter(filter, key, {"organization_id": 1}) | ||
|
||
def test_empty(self): | ||
self.run_test("=", "test", "IN", [SEMVER_EMPTY_RELEASE]) | ||
|
||
|
@@ -456,7 +457,7 @@ def test(self): | |
|
||
|
||
class ParseSemverTest(unittest.TestCase): | ||
def run_test(self, version: str, operator: str, expected: SemverFilter): | ||
def run_test(self, version: str | list[str], operator: str, expected: SemverFilter): | ||
semver_filter = parse_semver(version, operator) | ||
assert semver_filter == expected | ||
|
||
|
@@ -471,11 +472,6 @@ def test_invalid(self): | |
match=INVALID_SEMVER_MESSAGE, | ||
): | ||
assert parse_semver("hello", ">") is None | ||
with pytest.raises( | ||
InvalidSearchQuery, | ||
match="Invalid operation 'IN' for semantic version filter.", | ||
): | ||
assert parse_semver("1.2.3.4", "IN") is None | ||
|
||
def test_normal(self): | ||
self.run_test("1", ">", SemverFilter("gt", [1, 0, 0, 0, 1, ""])) | ||
|
@@ -493,6 +489,11 @@ def test_wildcard(self): | |
self.run_test("[email protected].*", "=", SemverFilter("exact", [1, 2, 3], "sentry")) | ||
self.run_test("1.X", "=", SemverFilter("exact", [1])) | ||
|
||
def test_in(self): | ||
self.run_test("1.2.3.4", "IN", SemverFilter("in", [1, 2, 3, 4, 1, ""])) | ||
# TODO: support not in operator | ||
# self.run_test("1.2.3.4", "NOT IN", SemverFilter("not in", [1, 2, 3, 4, 1, ""])) | ||
|
||
|
||
def _cond(lhs, op, rhs): | ||
return Condition(lhs=Column(name=lhs), op=op, rhs=rhs) | ||
|