2017-09-04 22:17:51 +08:00
|
|
|
from datetime import datetime
|
|
|
|
|
2019-08-20 15:54:41 +08:00
|
|
|
from django.db.models import DateTimeField, Value
|
2019-05-21 07:58:11 +08:00
|
|
|
from django.db.models.lookups import YearLookup
|
2017-09-04 22:17:51 +08:00
|
|
|
from django.test import SimpleTestCase
|
|
|
|
|
|
|
|
|
2019-05-21 07:58:11 +08:00
|
|
|
class YearLookupTests(SimpleTestCase):
|
|
|
|
def test_get_bound_params(self):
|
|
|
|
look_up = YearLookup(
|
2017-09-04 22:17:51 +08: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-21 07:58:11 +08:00
|
|
|
msg = 'subclasses of YearLookup must provide a get_bound_params() method'
|
2017-09-04 22:17:51 +08:00
|
|
|
with self.assertRaisesMessage(NotImplementedError, msg):
|
2019-05-21 07:58:11 +08:00
|
|
|
look_up.get_bound_params(datetime(2010, 1, 1, 0, 0, 0), datetime(2010, 1, 1, 23, 59, 59))
|