def test_json(self): name = "This is a test spot: {0}".format(random.random()) spot = Spot() spot.name = name spot.save() saved_id = spot.pk test_spot = Spot.objects.get(pk=saved_id) json_data = test_spot.json_data_structure() self.assertEqual(json_data["name"], name) self.assertEqual(json_data["id"], saved_id)
def test_json(self): dummy_cache = cache.get_cache( 'django.core.cache.backends.dummy.DummyCache') with patch.object(models, 'cache', dummy_cache): name = "This is a test spot: {0}".format(random.random()) spot = Spot() spot.name = name spot.save() saved_id = spot.pk test_spot = Spot.objects.get(pk=saved_id) json_data = test_spot.json_data_structure() self.assertEqual(json_data["name"], name, "The json structure has the right name") self.assertEqual(json_data["id"], saved_id, "The json structure has the right id")