def test(self): s = Shurl.objects.get(pk=1) t = Shurl.objects.get(pk=2) self.assertEqual(s.access_count, 1) self.assertEqual(t.access_count, 2) self.assertEqual(Domain.extract_domain_from_url(s.url), "http://www.test.com") d = Domain.get_or_create(s.url) self.assertEqual(d.access_count, 3)
def test(self): s = Shurl.objects.latest() d = Domain.get_or_create(s.url) m = d.monthlog_set.get(month=first_of_the_month()) old_m = d.monthlog_set.get(month=datetime.date(2012, 3, 1)) self.assertEqual(0, s.access_count) self.assertEqual(0, d.access_count) self.assertEqual(0, m.access_count) url = s.get_url() # re-pull s = Shurl.objects.latest() m = d.monthlog_set.get(month=first_of_the_month()) d = m.domain self.assertEqual(url, s.url) self.assertEqual(1, s.access_count) self.assertEqual(1, m.access_count) self.assertEqual(1, d.access_count) self.assertEqual(0, old_m.access_count)