2017-09-04 14:17:51 +00:00
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
from django.db.models import Value
|
|
|
|
from django.db.models.fields import DateTimeField
|
2019-05-20 23:58:11 +00:00
|
|
|
from django.db.models.lookups import YearLookup
|
2017-09-04 14:17:51 +00:00
|
|
|
from django.test import SimpleTestCase
|
|
|
|
|
|
|
|
|
2019-05-20 23:58:11 +00:00
|
|
|
class YearLookupTests(SimpleTestCase):
|
|
|
|
def test_get_bound_params(self):
|
|
|
|
look_up = YearLookup(
|
2017-09-04 14:17:51 +00:00
|
|
|
lhs=Value(datetime(2010, 1, 1, 0, 0, 0), output_field=DateTimeField()),
|
|
|
|
rhs=Value(datetime(2010, 1, 1, 23, 59, 59), output_field=DateTimeField()),
|
|
|
|
)
|
2019-05-20 23:58:11 +00:00
|
|
|
msg = 'subclasses of YearLookup must provide a get_bound_params() method'
|
2017-09-04 14:17:51 +00:00
|
|
|
with self.assertRaisesMessage(NotImplementedError, msg):
|
2019-05-20 23:58:11 +00:00
|
|
|
look_up.get_bound_params(datetime(2010, 1, 1, 0, 0, 0), datetime(2010, 1, 1, 23, 59, 59))
|