def test_config_ordering(self): with freeze_time('2012-01-01'): first = ExampleConfig(changed_by=self.user) first.string_field = 'first' first.save() second = ExampleConfig(changed_by=self.user) second.string_field = 'second' second.save() self.assertEqual(ExampleConfig.current().string_field, 'second')
def test_always_insert(self): config = ExampleConfig(changed_by=self.user, string_field='first') config.save() config.string_field = 'second' config.save() self.assertEqual(2, ExampleConfig.objects.all().count())
def test_cache_set(self): # Nothing is cached, so we take a database hit for this. with self.assertNumQueries(1): default = ExampleConfig.current() self.assertEqual(default.string_field, '') first = ExampleConfig(changed_by=self.user) first.string_field = 'first' first.save() # The save() call above should have invalidated the cache, so we expect # to see a query to get the current config value. with self.assertNumQueries(1): current = ExampleConfig.current() self.assertEqual(current.string_field, 'first')