def test_get_total_clicks(self):
        self.re_init_models()
        clicks_list = [20, 42, 33, 14, 55]
        for clicks in clicks_list:
            self.add_clicks(Advertiser(), clicks)

        self.assertEqual(sum(clicks_list), Advertiser.get_total_clicks())
        Advertiser.get_objects().clear()
Esempio n. 2
0
 def test_delete_fk(self):
     advertiser = Advertiser(name='hello')
     my_ad = Ad(advertiser=advertiser)
     Advertiser.get_objects().clear()
     try:
         my_ad.inc_clicks()
     except Exception:
         self.fail('failed to increase because of loss of fk')
 def test_id_inc(self):
     self.re_init_models()
     try:
         Advertiser()
         advertisers = Advertiser.get_objects()
         self.assertEqual(1, len(advertisers))
         try:
             Advertiser()
             self.assertEqual(2, len(advertisers))
         except Exception:
             self.fail("Exception in making ID")
     except Exception:
         self.fail("Exception in making ID")
 def re_init_models():
     Advertiser.get_objects().clear()