-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1902029 - Search input criteria of 12-40 characters is too restri…
…ctive (#8258) * Add new field author_contains to PushViewSet * Add iexact to the existing author param * Add test coverage
- Loading branch information
1 parent
b2231d1
commit dfa4b04
Showing
2 changed files
with
71 additions
and
2 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 |
---|---|---|
|
@@ -281,6 +281,16 @@ def test_push_author(client, test_repository): | |
assert len(results) == 2 # would have 3 if filter not applied | ||
assert set([result["id"] for result in results]) == set([1, 2]) | ||
|
||
# iexact looks for a case-insensitive match | ||
resp = client.get( | ||
reverse("push-list", kwargs={"project": test_repository.name}) + "[email protected]" | ||
) | ||
assert resp.status_code == 200 | ||
|
||
results = resp.json()["results"] | ||
assert len(results) == 2 # would have 3 if filter not applied | ||
assert set([result["id"] for result in results]) == set([1, 2]) | ||
|
||
resp = client.get( | ||
reverse("push-list", kwargs={"project": test_repository.name}) + "[email protected]" | ||
) | ||
|
@@ -299,6 +309,61 @@ def test_push_author(client, test_repository): | |
assert len(results) == 2 # would have 3 if filter not applied | ||
assert set([result["id"] for result in results]) == set([1, 2]) | ||
|
||
# iexact looks for a case-insensitive match | ||
resp = client.get( | ||
reverse("push-list", kwargs={"project": test_repository.name}) + "[email protected]" | ||
) | ||
assert resp.status_code == 200 | ||
|
||
results = resp.json()["results"] | ||
assert len(results) == 2 # would have 3 if filter not applied | ||
assert set([result["id"] for result in results]) == set([1, 2]) | ||
|
||
|
||
def test_push_author_contains(client, test_repository): | ||
""" | ||
test the author parameter | ||
""" | ||
for revision, author in [ | ||
("1234abcd", "[email protected]"), | ||
("2234abcd", "[email protected]"), | ||
("3234abcd", "[email protected]"), | ||
]: | ||
Push.objects.create( | ||
repository=test_repository, | ||
revision=revision, | ||
author=author, | ||
time=datetime.datetime.now(), | ||
) | ||
|
||
# icontains - case-insensitive containment test | ||
resp = client.get( | ||
reverse("push-list", kwargs={"project": test_repository.name}) + "?author_contains=fOo" | ||
) | ||
assert resp.status_code == 200 | ||
|
||
results = resp.json()["results"] | ||
assert len(results) == 2 | ||
assert set([result["id"] for result in results]) == set([1, 2]) | ||
|
||
resp = client.get( | ||
reverse("push-list", kwargs={"project": test_repository.name}) + "?author_contains=foO2" | ||
) | ||
assert resp.status_code == 200 | ||
|
||
results = resp.json()["results"] | ||
assert len(results) == 1 | ||
assert results[0]["id"] == 2 | ||
|
||
resp = client.get( | ||
reverse("push-list", kwargs={"project": test_repository.name}) + "?author_contains=qux" | ||
) | ||
assert resp.status_code == 200 | ||
|
||
results = resp.json()["results"] | ||
assert len(results) == 1 | ||
assert results[0]["id"] == 3 | ||
|
||
|
||
def test_push_reviewbot(client, test_repository): | ||
""" | ||
|
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