Permalink
Browse files

added TimeZoneField tests for model interaction (failing right now)

  • Loading branch information...
1 parent ff41b60 commit f88d0f29c72815a39a8e267a3b27d095667e9ad4 @brosner committed Mar 21, 2010
Showing with 23 additions and 0 deletions.
  1. +23 −0 timezones/timezones_tests/tests.py
@@ -71,6 +71,29 @@ class Meta:
bool(re.search(r'<option value="[\w/]+">\([A-Z]+(?:\+|\-)\d{4}\)\s[\w/]+</option>', rendered)),
"Did not find pattern in rendered form"
)
+
+ def test_models_string_value(self):
+ p = test_models.Profile(name="Brian Rosner", timezone="America/Denver")
+ p.save()
+ p = test_models.Profile.objects.get(pk=p.pk)
+ self.assertEqual(p.timezone, pytz.timezone("America/Denver"))
+
+ def test_models_string_value_lookup(self):
+ test_models.Profile(name="Brian Rosner", timezone="America/Denver").save()
+ qs = test_models.Profile.objects.filter(timezone="America/Denver")
+ self.assertEqual(qs.count(), 1)
+
+ def test_models_tz_value(self):
+ tz = pytz.timezone("America/Denver")
+ p = test_models.Profile(name="Brian Rosner", timezone=tz)
+ p.save()
+ p = test_models.Profile.objects.get(pk=p.pk)
+ self.assertEqual(p.timezone, tz)
+
+ def test_models_tz_value_lookup(self):
+ test_models.Profile(name="Brian Rosner", timezone="America/Denver").save()
+ qs = test_models.Profile.objects.filter(timezone=pytz.timezone("America/Denver"))
+ self.assertEqual(qs.count(), 1)
class LocalizedDateTimeFieldTestCase(TimeZoneTestCase):

0 comments on commit f88d0f2

Please sign in to comment.