def __importHitCount(self, zip, fingerprint, replacing): hits = json.loads(zip.read('hitcount.json'), object_hook=json_util.object_hook) tmap = None before = None if replacing: tmap = {} for hit in hits: this_hit = HitCount() if replacing: hit['object_pk'] = fingerprint.id before = hit['id'] del hit['id'] this_hit.__dict__.update(hit) this_hit.save() if replacing: tmap[before] = this_hit.id return tmap
def test_string_representation(self): """ Basic __str__ testing """ post = Post.objects.create(title='my title', content='my text') hit_count = HitCount(content_object=post) self.assertEqual(hit_count.__str__(), 'Post title: my title')