-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support for Django 4 * Change pytest-django version * Change psycopg2 version * Change pytest version * Change tox version * Change pytest-cov version * Update circle ci jobs * Fix ci jobs * Update ci to postgres 12 * Allow Django 5.0 * Bump Django min version to 3.2 * Fix CI to account for >= 3.2 requirement * Fix quote * Remove python 3.12 for now due to distutils removal * Remove Django upper bound * Add back python3.6,3.7 wfs * Downgrade dj-database-url * Fix isnull issue from Django 4
- Loading branch information
1 parent
a55986d
commit 5bb16af
Showing
6 changed files
with
161 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import django | ||
import pytest | ||
|
||
from django.test import TestCase | ||
|
||
from localized_fields.fields import LocalizedField | ||
from localized_fields.value import LocalizedValue | ||
|
||
from .fake_model import get_fake_model | ||
|
||
|
||
class LocalizedIsNullLookupsTestCase(TestCase): | ||
"""Tests whether ref lookups properly work with.""" | ||
|
||
TestModel1 = None | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
"""Creates the test model in the database.""" | ||
super(LocalizedIsNullLookupsTestCase, cls).setUpClass() | ||
cls.TestModel = get_fake_model( | ||
{"text": LocalizedField(null=True, required=[])} | ||
) | ||
cls.TestModel.objects.create( | ||
text=LocalizedValue(dict(en="text_en", ro="text_ro", nl="text_nl")) | ||
) | ||
cls.TestModel.objects.create( | ||
text=None, | ||
) | ||
|
||
def test_isnull_lookup_valid_values(self): | ||
"""Test whether isnull properly works with valid values.""" | ||
assert self.TestModel.objects.filter(text__isnull=True).exists() | ||
assert self.TestModel.objects.filter(text__isnull=False).exists() | ||
|
||
def test_isnull_lookup_null(self): | ||
"""Test whether isnull crashes with None as value.""" | ||
|
||
with pytest.raises(ValueError): | ||
assert self.TestModel.objects.filter(text__isnull=None).exists() | ||
|
||
def test_isnull_lookup_string(self): | ||
"""Test whether isnull properly works with string values on the | ||
corresponding Django version.""" | ||
if django.VERSION < (4, 0): | ||
assert self.TestModel.objects.filter(text__isnull="True").exists() | ||
else: | ||
with pytest.raises(ValueError): | ||
assert self.TestModel.objects.filter( | ||
text__isnull="True" | ||
).exists() |
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