-
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 #393 from UW-GAC/feature/add-search-functionality-…
…for-models Feature/add search functionality for models Closes #294
- Loading branch information
Showing
34 changed files
with
861 additions
and
73 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 |
---|---|---|
|
@@ -28,10 +28,6 @@ jobs: | |
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.9" | ||
cache: pip | ||
cache-dependency-path: | | ||
requirements/base.txt | ||
requirements/dev.txt | ||
|
||
- name: Run pre-commit | ||
uses: pre-commit/[email protected] | ||
|
@@ -41,7 +37,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
max-parallel: 5 | ||
max-parallel: 10 | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
|
||
|
@@ -59,7 +55,15 @@ jobs: | |
python -m pip install --upgrade tox tox-gh-actions | ||
- name: Test with tox | ||
run: tox | ||
# Sometimes tox fails to build the package correctly and intermittently throws an OSError or BadZipFile error. | ||
# Upon retry, it seems to work. | ||
uses: nick-fields/retry@v2 | ||
id: retry-sqlite | ||
with: | ||
timeout_minutes: 10 | ||
max_attempts: 3 | ||
retry_on: error | ||
command: tox | ||
env: | ||
DBBACKEND: sqlite3 | ||
DBNAME: ":memory:" | ||
|
@@ -75,10 +79,10 @@ jobs: | |
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
max-parallel: 5 | ||
max-parallel: 10 | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
mariadb-version: ["10.3", "10.5"] | ||
mariadb-version: ["10.4"] | ||
|
||
services: | ||
database: | ||
|
@@ -103,19 +107,16 @@ jobs: | |
python -m pip install --upgrade pip | ||
python -m pip install --upgrade tox tox-gh-actions | ||
- name: Test with tox - 10.3 | ||
if: ${{ matrix.mariadb-version == '10.3' }} | ||
run: tox --skip-env ".+?-django42-mysql" | ||
env: | ||
DBBACKEND: mysql | ||
DBNAME: test | ||
DBUSER: root | ||
DBPASSWORD: rootpw | ||
DBHOST: 127.0.0.1 | ||
|
||
- name: Test with tox - not 10.3 | ||
if: ${{ matrix.mariadb-version != '10.3' }} | ||
run: tox | ||
- name: Test with tox | ||
# Sometimes tox fails to build the package correctly and intermittently throws an OSError or BadZipFile error. | ||
# Upon retry, it seems to work. | ||
uses: nick-fields/retry@v2 | ||
id: retry-mysql | ||
with: | ||
timeout_minutes: 10 | ||
max_attempts: 3 | ||
retry_on: error | ||
command: tox | ||
env: | ||
DBBACKEND: mysql | ||
DBNAME: test | ||
|
@@ -143,7 +144,6 @@ jobs: | |
|
||
- run: python -m pip install --upgrade coverage[toml] django==3.2.16 django-coverage-plugin | ||
|
||
|
||
- name: Download coverage data. | ||
uses: actions/download-artifact@v3 | ||
with: | ||
|
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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.18" | ||
__version__ = "0.19dev1" |
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,31 @@ | ||
from django_filters import FilterSet | ||
|
||
from . import forms, models | ||
|
||
|
||
class AccountListFilter(FilterSet): | ||
class Meta: | ||
model = models.Account | ||
fields = {"email": ["icontains"]} | ||
form = forms.FilterForm | ||
|
||
|
||
class BillingProjectListFilter(FilterSet): | ||
class Meta: | ||
model = models.BillingProject | ||
fields = {"name": ["icontains"]} | ||
form = forms.FilterForm | ||
|
||
|
||
class ManagedGroupListFilter(FilterSet): | ||
class Meta: | ||
model = models.ManagedGroup | ||
fields = {"name": ["icontains"]} | ||
form = forms.FilterForm | ||
|
||
|
||
class WorkspaceListFilter(FilterSet): | ||
class Meta: | ||
model = models.Workspace | ||
fields = {"name": ["icontains"]} | ||
form = forms.FilterForm |
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 |
---|---|---|
|
@@ -10,11 +10,12 @@ | |
BaseWorkspaceAdapter, | ||
WorkspaceAdapterRegistry, | ||
) | ||
from ..filters import AccountListFilter, BillingProjectListFilter | ||
from ..forms import DefaultWorkspaceDataForm, WorkspaceForm | ||
from ..models import Account, DefaultWorkspaceData | ||
from ..tables import AccountTable, WorkspaceTable | ||
from . import factories | ||
from .test_app import forms, models, tables | ||
from .test_app import filters, forms, models, tables | ||
from .test_app.adapters import TestWorkspaceAdapter | ||
|
||
|
||
|
@@ -26,6 +27,7 @@ def get_test_adapter(self): | |
|
||
class TestAdapter(BaseAccountAdapter): | ||
list_table_class = tables.TestAccountTable | ||
list_filterset_class = filters.TestAccountListFilter | ||
|
||
return TestAdapter | ||
|
||
|
@@ -46,6 +48,45 @@ def test_list_table_class_none(self): | |
with self.assertRaises(ImproperlyConfigured): | ||
TestAdapter().get_list_table_class() | ||
|
||
def test_list_filterset_class_default(self): | ||
"""get_list_filterset_class returns the correct filter when using the default adapter.""" | ||
self.assertEqual( | ||
DefaultAccountAdapter().get_list_filterset_class(), AccountListFilter | ||
) | ||
|
||
def test_list_filterset_class_custom(self): | ||
"""get_list_filterset_class returns the correct filter when using a custom adapter.""" | ||
TestAdapter = self.get_test_adapter() | ||
setattr(TestAdapter, "list_filterset_class", filters.TestAccountListFilter) | ||
self.assertEqual( | ||
TestAdapter().get_list_filterset_class(), filters.TestAccountListFilter | ||
) | ||
|
||
def test_list_filterset_class_none(self): | ||
"""get_list_filterset_class raises ImproperlyConfigured when get_list_filterset_class is not set.""" | ||
TestAdapter = self.get_test_adapter() | ||
setattr(TestAdapter, "list_filterset_class", None) | ||
with self.assertRaises(ImproperlyConfigured): | ||
TestAdapter().get_list_filterset_class() | ||
|
||
def test_list_filterset_class_different_model(self): | ||
"""get_list_filterset_class raises ImproperlyConfigured when incorrect model is used.""" | ||
TestAdapter = self.get_test_adapter() | ||
setattr(TestAdapter, "list_filterset_class", BillingProjectListFilter) | ||
with self.assertRaises(ImproperlyConfigured): | ||
TestAdapter().get_list_filterset_class() | ||
|
||
def test_list_filterset_class_not_filterset(self): | ||
"""get_list_filterset_class raises ImproperlyConfigured when not a subclass of FilterSet.""" | ||
|
||
class Foo: | ||
pass | ||
|
||
TestAdapter = self.get_test_adapter() | ||
setattr(TestAdapter, "list_filterset_class", Foo) | ||
with self.assertRaises(ImproperlyConfigured): | ||
TestAdapter().get_list_filterset_class() | ||
|
||
def test_get_autocomplete_queryset_default(self): | ||
"""get_autocomplete_queryset returns the correct queryset when using the default adapter.""" | ||
account_1 = factories.AccountFactory.create(email="[email protected]") | ||
|
Oops, something went wrong.