def test_get_home_filter_logged_results(self):
     home = HomeForSaleAdFactory.create()
     user = UserFactory.create(password="******")
     self.c.login(username=user.username, password='******')
     resp = self.c.get(reverse('search', 'sites.achetersanscom.urls'), {'foo': 'bar'})
     self.assertEqual(resp.status_code, 200)
     home.delete()
 def test_create_search(self):
     logger.info('HomeForSaleAdSearch create')
     search = 'separate_dining_room=1&energy_consumption=&terrace=1&parking=&separate_toilet=1&doorman=1&balcony=1&nb_of_rooms_1=&nb_of_rooms_0=&bathroom=1&duplex=1&floor_0=&elevator=1&surface_1=&location=&top_floor=1&nb_of_bedrooms_1=&nb_of_bedrooms_0=&surface_0=&not_overlooked=1&cellar=1&separate_entrance=1&digicode=1&intercom=1&search=search&air_conditioning=1&fireplace=&floor_1=&kitchen=1&price_1=&price_0=&ground_floor=1&alarm=1&heating=&shower=1&swimming_pool=1&emission_of_greenhouse_gases='
     home_search = HomeForSaleAdSearchFactory.create(search=search,
         content_type=ContentType.objects.get_for_model(HomeForSaleAd))
     #print 'len', len(mail.outbox)
     #print homeforsalead_search.content_type
     #print ContentType.objects.get_for_model(HomeForSaleAd)
     #print HomeForSaleAd.objects.all()
     logger.info('HomeForSaleAd create')
     home = HomeForSaleAdFactory.create(price="21")
     #nb_of_mails = len(mail.outbox)
     #ModeratedObject.objects.all()[0].approve()
     logger.info('HomeForSaleAd is moderated')
     home.moderated_object.approve()
     #print '>>>>>>>>>>>>', len(mail.outbox) - nb_of_mails
     #print 'len', len(mail.outbox)
     #for m in mail.outbox:
     #    print m.subject
     home_search.public = True
     logger.info("HomeForSaleAdSearch is now public, we should send some mails to vendors for potential buyers")
     home_search.save()
     #print '>>>>>>>>>>>>', len(mail.outbox) - nb_of_mails
     #print 'len', len(mail.outbox)
     #for m in mail.outbox:
     #    print m.subject
     home_search.delete()
     home.delete()
 def test_get_update_homeforsale(self):
     # test for user that doesn't own the ad => throw 404
     home = HomeForSaleAdFactory.create()
     user = UserFactory.create(password="******")
     self.c.login(username=user.username, password='******')
     resp = self.c.get(reverse('edit', 'sites.achetersanscom.urls', kwargs={'pk': home.id}))
     self.assertEqual(resp.status_code, 404)
 def test_get_home_filter_logged_results(self):
     home = HomeForSaleAdFactory.create()
     user = UserFactory.create(password="******")
     self.c.login(username=user.username, password="******")
     resp = self.c.get(reverse("search", "sites.achetersanscom.urls"), {"foo": "bar"})
     self.assertEqual(resp.status_code, 200)
     home.delete()
 def test_create_search(self):
     logger.info("HomeForSaleAdSearch create")
     search = "separate_dining_room=1&energy_consumption=&terrace=1&parking=&separate_toilet=1&doorman=1&balcony=1&nb_of_rooms_1=&nb_of_rooms_0=&bathroom=1&duplex=1&floor_0=&elevator=1&surface_1=&location=&top_floor=1&nb_of_bedrooms_1=&nb_of_bedrooms_0=&surface_0=&not_overlooked=1&cellar=1&separate_entrance=1&digicode=1&intercom=1&search=search&air_conditioning=1&fireplace=&floor_1=&kitchen=1&price_1=&price_0=&ground_floor=1&alarm=1&heating=&shower=1&swimming_pool=1&emission_of_greenhouse_gases="
     home_search = HomeForSaleAdSearchFactory.create(
         search=search, content_type=ContentType.objects.get_for_model(HomeForSaleAd)
     )
     # print 'len', len(mail.outbox)
     # print homeforsalead_search.content_type
     # print ContentType.objects.get_for_model(HomeForSaleAd)
     # print HomeForSaleAd.objects.all()
     logger.info("HomeForSaleAd create")
     home = HomeForSaleAdFactory.create(price="21")
     # nb_of_mails = len(mail.outbox)
     # ModeratedObject.objects.all()[0].approve()
     logger.info("HomeForSaleAd is moderated")
     home.moderated_object.approve()
     # print '>>>>>>>>>>>>', len(mail.outbox) - nb_of_mails
     # print 'len', len(mail.outbox)
     # for m in mail.outbox:
     #    print m.subject
     home_search.public = True
     logger.info("HomeForSaleAdSearch is now public, we should send some mails to vendors for potential buyers")
     home_search.save()
     # print '>>>>>>>>>>>>', len(mail.outbox) - nb_of_mails
     # print 'len', len(mail.outbox)
     # for m in mail.outbox:
     #    print m.subject
     home_search.delete()
     home.delete()
 def test_get_update_homeforsale(self):
     # test for user that doesn't own the ad => throw 404
     home = HomeForSaleAdFactory.create()
     user = UserFactory.create(password="******")
     self.c.login(username=user.username, password="******")
     resp = self.c.get(reverse("edit", "sites.achetersanscom.urls", kwargs={"pk": home.id}))
     self.assertEqual(resp.status_code, 404)
 def test_post_update_homeforsale(self):
     home = HomeForSaleAdFactory.create()
     user = home.user
     user.password = make_password('bla')
     user.save()
     self.c.login(username=user.username, password='******')
     resp = self.c.post(reverse('edit', 'sites.achetersanscom.urls', kwargs={'pk': home.id}))
     self.assertEqual(resp.status_code, 200)
 def test_post_update_homeforsale(self):
     home = HomeForSaleAdFactory.create()
     user = home.user
     user.password = make_password("bla")
     user.save()
     self.c.login(username=user.username, password="******")
     resp = self.c.post(reverse("edit", "sites.achetersanscom.urls", kwargs={"pk": home.id}))
     self.assertEqual(resp.status_code, 200)
 def test_create_home(self):
     # see if moderation works fine
     home = HomeForSaleAdFactory.create(price="20")
     self.assertEquals(HomeForSaleAd.objects.all().count(), 0)
     self.assertEquals(ModeratedObject.objects.all().count(), 1)
     home.moderated_object.approve()
     self.assertEquals(HomeForSaleAd.objects.all().count(), 1)
     self.assertEquals(ModeratedObject.objects.all().count(), 1)
     self.assertEquals(len(mail.outbox), 3)
     home.delete()
 def test_create_home(self):
     # see if moderation works fine
     home = HomeForSaleAdFactory.create(price="20")
     self.assertEquals(HomeForSaleAd.objects.all().count(), 0)
     self.assertEquals(ModeratedObject.objects.all().count(), 1)
     home.moderated_object.approve()
     self.assertEquals(HomeForSaleAd.objects.all().count(), 1)
     self.assertEquals(ModeratedObject.objects.all().count(), 1)
     self.assertEquals(len(mail.outbox), 3)
     home.delete()
 def test_get_home_filter_not_logged_results(self):
     home = HomeForSaleAdFactory.create()
     resp = self.c.get(reverse('search', 'sites.achetersanscom.urls'), {'foo': 'bar'})
     self.assertEqual(resp.status_code, 200)
     home.delete()
 def test_get_home_filter_not_logged_results(self):
     home = HomeForSaleAdFactory.create()
     resp = self.c.get(reverse("search", "sites.achetersanscom.urls"), {"foo": "bar"})
     self.assertEqual(resp.status_code, 200)
     home.delete()