Exemple #1
0
 def test_create_update_read__delete_search(self):
     test_ad = TestAdFactory.create()
     # here we build a search ad form
     # create
     location = "SRID%3D900913%3BPOLYGON((2.3886182861327825+48.834761790252024%2C2.2773817138671575+48.837925498723266%2C2.3251035766601262+48.87180983721773%2C2.4023511962890325+48.87293892019383%2C2.3886182861327825+48.834761790252024))"
     request = self.factory.post('/', data={'search': 'brand=' + test_ad.brand + '&location=' + location})
     user = UserFactory.create()
     request.user = user
     response = views.AdSearchView.as_view(model=TestAd)(request)
     ad_search = AdSearch.objects.all().filter(user=user)[0]
     # update
     request = self.factory.post('/', data={'search': 'brand=' + test_ad.brand})
     request.user = user
     response = views.AdSearchView.as_view(model=TestAd)(request, search_id=ad_search.pk)
     # read
     request = self.factory.get('/')
     request.user = user
     response = views.AdSearchView.as_view(model=TestAd)(request, search_id=ad_search.pk)
     not_ad_search_owner_user = UserFactory.create()
     request = self.factory.get('/')
     request.user = not_ad_search_owner_user
     view = views.AdSearchView.as_view(model=TestAd)
     self.assertRaises(Http404, view, request, search_id=ad_search.pk)
     # delete
     request = self.factory.get('/')
     # by non authorized user
     request.user = not_ad_search_owner_user
     view = views.AdSearchDeleteView.as_view()
     self.assertRaises(Http404, view, request, pk=ad_search.pk)
     # by authorized user (owner of ad search)
     request = self.factory.post('/')
     request.user = ad_search.user
     response = views.AdSearchDeleteView.as_view()(request, pk=ad_search.pk)
Exemple #2
0
 def test_ad_adsearch_and_ads_notifications_3(self):
     # ad Ad, then AdSearch corresponding public True => mail to buyer and vendor
     ad = TestAdFactory.create(brand="myfunkybrand")
     adsearch = TestAdSearchFactory.create(search="brand=myfunkybrand",
         content_type=ContentType.objects.get_for_model(TestAd), public=True)
     self.assertEquals(len(mail.outbox), 2)
     adsearch.delete()
     ad.delete()
Exemple #3
0
 def test_send_message(self):
     with mock_signal_receiver(geoad_user_message) as user_message:
         test_ad = TestAdFactory.create()
         user = UserFactory.create()
         request = self.factory.post('/', data={'message': 'Hi buddy !'})
         request.user = user
         response = views.AdDetailView.as_view(model=TestAd)(request, pk=test_ad.pk)
         # verify mail is sent
         self.assertEquals(user_message.call_count, 1)
Exemple #4
0
 def test_ad_model_property(self):
     ad = TestAdFactory.create(brand="myfunkybrand")
     adsearch = TestAdSearchFactory.create(search="brand=myfunkybrand",
                                           content_type=ContentType.objects.get_for_model(TestAd),
                                           public=True)
     self.assertEqual(ad.public_adsearch, [adsearch, ])
     adsearch.public = False
     adsearch.save()
     self.assertEqual(ad.public_adsearch, [])
Exemple #5
0
 def test_ad_search_result_remove(self):
     ad = TestAdFactory.create(brand="myfunkybrand")
     adsearch = TestAdSearchFactory.create(search="brand=myfunkybrand",
                                           content_type=ContentType.objects.get_for_model(TestAd),
                                           public=True)
     ad.brand = "mytoofunkybrand"
     ad.save()
     ad.delete()
     adsearch.delete()
Exemple #6
0
 def test_ad_adsearch_and_ads_notifications_4(self):
     # ad Ad, then AdSearch corresponding public False => mail to buyer
     ad = TestAdFactory.create(brand="myfunkybrand")
     adsearch = TestAdSearchFactory.create(search="brand=myfunkybrand",
         content_type=ContentType.objects.get_for_model(TestAd), public=False)
     self.assertEquals(len(mail.outbox), 1)
     # the AdSearch become public, then mail to the vendor
     adsearch.public = True
     adsearch.save()
     self.assertEquals(len(mail.outbox), 2)
Exemple #7
0
 def test_send_message(self):
     with mock_signal_receiver(geoad_user_message) as user_message:
         test_ad = TestAdFactory.create()
         user = UserFactory.create()
         request = self.factory.post('/', data={'message': 'Hi buddy !'})
         request.user = user
         response = views.AdDetailView.as_view(model=TestAd)(request,
                                                             pk=test_ad.pk)
         # verify mail is sent
         self.assertEquals(user_message.call_count, 1)
Exemple #8
0
 def test_ad_search_result_remove(self):
     ad = TestAdFactory.create(brand="myfunkybrand")
     adsearch = TestAdSearchFactory.create(
         search="brand=myfunkybrand",
         content_type=ContentType.objects.get_for_model(TestAd),
         public=True)
     ad.brand = "mytoofunkybrand"
     ad.save()
     ad.delete()
     adsearch.delete()
Exemple #9
0
 def test_view(self):
     # create ad and an adsearch
     adsearch = TestAdSearchFactory.create(search="brand=myfunkybrand",
                                           content_type=ContentType.objects.get_for_model(TestAd),
                                           public=True)
     ad = TestAdFactory.create(brand="myfunkybrand")
     request = self.factory.get('/')
     request.user = ad.user
     response = views.AdPotentialBuyersView.as_view(model=TestAd)(request, pk=ad.id)
     self.assertEqual(response.context_data['object'], ad)
     self.assertEqual(response.context_data['object_list'][0], adsearch.adsearchresult_set.all()[0])
Exemple #10
0
 def test_ad_model_property(self):
     ad = TestAdFactory.create(brand="myfunkybrand")
     adsearch = TestAdSearchFactory.create(
         search="brand=myfunkybrand",
         content_type=ContentType.objects.get_for_model(TestAd),
         public=True)
     self.assertEqual(ad.public_adsearch, [
         adsearch,
     ])
     adsearch.public = False
     adsearch.save()
     self.assertEqual(ad.public_adsearch, [])
Exemple #11
0
 def test_owner_delete(self):
     # create an ad and test if owner can delete it
     test_ad = TestAdFactory.create()
     request = self.factory.get('/')
     request.user = test_ad.user
     response = views.AdDeleteView.as_view(model=TestAd)(request, pk=test_ad.pk)
     self.assertEqual(response.status_code, 200)
     request = self.factory.post('/')
     request.user = test_ad.user
     response = views.AdDeleteView.as_view(model=TestAd)(request, pk=test_ad.pk)
     self.assertEqual(response.status_code, 302)
     self.assertRaises(TestAd.DoesNotExist, TestAd.objects.get, id=test_ad.id)
Exemple #12
0
 def test_not_owner_delete(self):
     # create a user, and an ad, and test if the user
     # who is not the ad owner can't delete it
     test_ad = TestAdFactory.create()
     user = UserFactory.create()
     request = self.factory.get('/')
     request.user = user
     view = views.AdDeleteView.as_view(model=TestAd)
     self.assertRaises(Http404, view, request, pk=test_ad.pk)
     request = self.factory.post('/')
     request.user = user
     view = views.AdDeleteView.as_view(model=TestAd)
     self.assertRaises(Http404, view, request, pk=test_ad.pk)
Exemple #13
0
 def test_not_owner_delete(self):
     # Create a user and an ad
     # Test if the user who is not the ad owner can't delete it
     test_ad = TestAdFactory.create()
     user = UserFactory.create()
     request = self.factory.get('/')
     request.user = user
     view = views.AdDeleteView.as_view(model=TestAd)
     self.assertRaises(Http404, view, request, pk=test_ad.pk)
     request = self.factory.post('/')
     request.user = user
     view = views.AdDeleteView.as_view(model=TestAd)
     self.assertRaises(Http404, view, request, pk=test_ad.pk)
     self.assertTrue(test_ad in TestAd.objects.all())
Exemple #14
0
 def test_view(self):
     # create ad and an adsearch
     adsearch = TestAdSearchFactory.create(
         search="brand=myfunkybrand",
         content_type=ContentType.objects.get_for_model(TestAd),
         public=True)
     ad = TestAdFactory.create(brand="myfunkybrand")
     request = self.factory.get('/')
     request.user = ad.user
     response = views.AdPotentialBuyersView.as_view(model=TestAd)(request,
                                                                  pk=ad.id)
     self.assertEqual(response.context_data['object'], ad)
     self.assertEqual(response.context_data['object_list'][0],
                      adsearch.adsearchresult_set.all()[0])
Exemple #15
0
 def test_view(self):
     # create ad and an adsearch
     adsearch = TestAdSearchFactory.create(search="brand=myfunkybrand",
                                           content_type=ContentType.objects.get_for_model(TestAd),
                                           public=True)
     ad = TestAdFactory.create(brand="myfunkybrand")
     request = self.factory.get('/')
     request.user = ad.user
     response = views.AdPotentialBuyerContactView.as_view()(request,
             adsearchresult_id=adsearch.adsearchresult_set.all()[0])
     request = self.factory.post('/', data={'message': 'I love your ad'}, files=[])
     request.user = ad.user
     response = views.AdPotentialBuyerContactView.as_view()(request,
             adsearchresult_id=adsearch.adsearchresult_set.all()[0])
Exemple #16
0
 def test_ad_adsearch_and_ads_signals_3(self):
     """
     Test if signals are well sent to the buyer and the seller
     in case the search is created after the ad
     and initially with public set to True
     """
     with mock_signal_receiver(geoad_new_relevant_ad_for_search) as receiver_buyer:
         with mock_signal_receiver(geoad_new_interested_user) as receiver_vendor:
             ad = TestAdFactory.create(brand="myfunkybrand")
             adsearch = TestAdSearchFactory.create(search="brand=myfunkybrand",
                                                   content_type=ContentType.objects.get_for_model(TestAd),
                                                   public=True)
             self.assertEquals(receiver_buyer.call_count, 1)
             self.assertEquals(receiver_vendor.call_count, 1)
             adsearch.delete()
             ad.delete()
Exemple #17
0
 def test_owner_update(self):
     test_ad = TestAdFactory.create()
     form_data = {
         'brand': test_ad.brand,
         'location': test_ad.location,
         'user_entered_address': test_ad.user_entered_address,
         'geoads-adpicture-content_type-object_id-TOTAL_FORMS': 4,
         'geoads-adpicture-content_type-object_id-INITIAL_FORMS': 0}
     request = self.factory.get('/')
     request.user = test_ad.user
     response = views.AdUpdateView.as_view(model=TestAd, form_class=TestAdForm)(request, pk=test_ad.pk)
     self.assertEqual(response.status_code, 200)
     request = self.factory.post('/', data=form_data)
     request.user = test_ad.user
     response = views.AdUpdateView.as_view(model=TestAd, form_class=TestAdForm)(request, pk=test_ad.pk)
     self.assertEqual(response.status_code, 301)
Exemple #18
0
 def test_remove_ad_from_ad_search(self):
     with mock_signal_receiver(geoad_new_relevant_ad_for_search) as receiver_buyer:
         with mock_signal_receiver(geoad_new_interested_user) as receiver_vendor:
             adsearch = TestAdSearchFactory.create(search="brand=myfunkybrand",
                                                   content_type=ContentType.objects.get_for_model(TestAd),
                                                   public=True)
             ad = TestAdFactory.create(brand="myfunkybrand")
             self.assertEquals(receiver_buyer.call_count, 1)
             self.assertEquals(receiver_vendor.call_count, 1)
             # modify Ad to correspond => signal to buyer
             ad.brand = "mytoofunkybrand"
             ad.save()
             self.assertEquals(receiver_buyer.call_count, 1)
             self.assertEquals(receiver_vendor.call_count, 1)
             adsearch.delete()
             ad.delete()
Exemple #19
0
 def test_adsignal(self):
     #test_ad = TestAdFactory.create()
     # here we create an AdSearch that should hold all ads
     test_adsearch = TestAdSearchFactory.create(content_type=ContentType.objects.get_for_model(TestAd))
     # here we create an Ad, and should then get it inside AdSearchResult of test_adsearch
     test_ad = TestAdFactory.create()
     self.assertEqual(test_adsearch.adsearchresult_set.all().count(), 1)
     test_adsearch.search = "brand=myfunkybrand"
     test_adsearch.save()
     self.assertEqual(test_adsearch.adsearchresult_set.all().count(), 0)
     test_adsearch.search = "brand=%s" % (test_ad.brand)
     test_adsearch.save()
     self.assertEqual(test_adsearch.adsearchresult_set.all().count(), 1)
     test_ad.brand = "newbrandnameduetofuckingmarketingservice"
     test_ad.save()
     self.assertEqual(test_adsearch.adsearchresult_set.all().count(), 0)
Exemple #20
0
 def test_view(self):
     # create ad and an adsearch
     adsearch = TestAdSearchFactory.create(
         search="brand=myfunkybrand",
         content_type=ContentType.objects.get_for_model(TestAd),
         public=True)
     ad = TestAdFactory.create(brand="myfunkybrand")
     request = self.factory.get('/')
     request.user = ad.user
     response = views.AdPotentialBuyerContactView.as_view()(
         request, adsearchresult_id=adsearch.adsearchresult_set.all()[0])
     request = self.factory.post('/',
                                 data={'message': 'I love your ad'},
                                 files=[])
     request.user = ad.user
     response = views.AdPotentialBuyerContactView.as_view()(
         request, adsearchresult_id=adsearch.adsearchresult_set.all()[0])
Exemple #21
0
 def test_not_owner_update(self):
     test_ad = TestAdFactory.create()
     user = UserFactory.create()
     form_data = {
         'brand': test_ad.brand,
         'location': test_ad.location,
         'user_entered_address': test_ad.user_entered_address,
         'geoads-adpicture-content_type-object_id-TOTAL_FORMS': 4,
         'geoads-adpicture-content_type-object_id-INITIAL_FORMS': 0}
     request = self.factory.get('/')
     request.user = user
     view = views.AdUpdateView.as_view(model=TestAd, form_class=TestAdForm)
     self.assertRaises(Http404, view, request, pk=test_ad.pk)
     request = self.factory.post('/', data=form_data)
     request.user = user
     view = views.AdUpdateView.as_view(model=TestAd, form_class=TestAdForm)
     self.assertRaises(Http404, view, request, pk=test_ad.pk)
Exemple #22
0
 def test_not_owner_update(self):
     test_ad = TestAdFactory.create()
     user = UserFactory.create()
     form_data = {
         'brand': test_ad.brand,
         'location': test_ad.location,
         'user_entered_address': test_ad.user_entered_address,
         'geoads-adpicture-content_type-object_id-TOTAL_FORMS': 4,
         'geoads-adpicture-content_type-object_id-INITIAL_FORMS': 0
     }
     request = self.factory.get('/')
     request.user = user
     view = views.AdUpdateView.as_view(model=TestAd, form_class=TestAdForm)
     self.assertRaises(Http404, view, request, pk=test_ad.pk)
     request = self.factory.post('/', data=form_data)
     request.user = user
     view = views.AdUpdateView.as_view(model=TestAd, form_class=TestAdForm)
     self.assertRaises(Http404, view, request, pk=test_ad.pk)
Exemple #23
0
 def test_owner_delete(self):
     # Create an ad
     # Test if owner can delete it
     test_ad = TestAdFactory.create()
     request = self.factory.get('/')
     request.user = test_ad.user
     response = views.AdDeleteView.as_view(model=TestAd)(request,
                                                         pk=test_ad.pk)
     self.assertEqual(response.status_code, 200)
     request = self.factory.post('/')
     request.user = test_ad.user
     response = views.AdDeleteView.as_view(model=TestAd)(request,
                                                         pk=test_ad.pk)
     self.assertEqual(response.status_code, 302)
     self.assertRaises(TestAd.DoesNotExist,
                       TestAd.objects.get,
                       id=test_ad.id)
     self.assertFalse(test_ad in TestAd.objects.all())
Exemple #24
0
 def test_ad_adsearch_and_ads_signals_3(self):
     """
     Test if signals are well sent to the buyer and the seller
     in case the search is created after the ad
     and initially with public set to True
     """
     with mock_signal_receiver(
             geoad_new_relevant_ad_for_search) as receiver_buyer:
         with mock_signal_receiver(
                 geoad_new_interested_user) as receiver_vendor:
             ad = TestAdFactory.create(brand="myfunkybrand")
             adsearch = TestAdSearchFactory.create(
                 search="brand=myfunkybrand",
                 content_type=ContentType.objects.get_for_model(TestAd),
                 public=True)
             self.assertEquals(receiver_buyer.call_count, 1)
             self.assertEquals(receiver_vendor.call_count, 1)
             adsearch.delete()
             ad.delete()
Exemple #25
0
    def test_ad_adsearch_and_ads_signals_5(self):
        """
        Mixed case where we change the different fields of ad and addsearch
        """
        with mock_signal_receiver(
                geoad_new_relevant_ad_for_search) as receiver_buyer:
            with mock_signal_receiver(
                    geoad_new_interested_user) as receiver_vendor:
                ad = TestAdFactory.create(brand="myfunkybrand")
                adsearch = TestAdSearchFactory.create(
                    search="brand=mytoofunkybrand",
                    content_type=ContentType.objects.get_for_model(TestAd),
                    public=True)

                self.assertEquals(receiver_buyer.call_count, 0)
                self.assertEquals(receiver_vendor.call_count, 0)
                # modify Ad to correspond => signal to buyer
                ad.brand = "mytoofunkybrand"
                ad.save()
                self.assertEquals(receiver_buyer.call_count, 1)
                self.assertEquals(receiver_vendor.call_count, 1)
                # resave Ad to be sure, signal isn't send one more time
                ad.brand = "mytoofunkybrand"
                ad.save()
                self.assertEquals(receiver_buyer.call_count, 1)
                self.assertEquals(receiver_vendor.call_count, 1)
                # modify AdSearch to not correspond
                adsearch.search = "brand=myfunkybrand"
                adsearch.save()
                self.assertEquals(receiver_buyer.call_count, 1)
                self.assertEquals(receiver_vendor.call_count, 1)
                # modify AdSearch to corresond => mail to both
                ad.brand = "myfunkybrand"
                ad.save()
                self.assertEquals(receiver_buyer.call_count, 2)
                self.assertEquals(receiver_vendor.call_count, 2)
                # just change the Ad description to be sure signal is not sent another time
                ad.description = "you must buy it"
                ad.save()
                self.assertEquals(receiver_buyer.call_count, 2)
                self.assertEquals(receiver_vendor.call_count, 2)
                adsearch.delete()
                ad.delete()
Exemple #26
0
 def test_remove_ad_from_ad_search(self):
     with mock_signal_receiver(
             geoad_new_relevant_ad_for_search) as receiver_buyer:
         with mock_signal_receiver(
                 geoad_new_interested_user) as receiver_vendor:
             adsearch = TestAdSearchFactory.create(
                 search="brand=myfunkybrand",
                 content_type=ContentType.objects.get_for_model(TestAd),
                 public=True)
             ad = TestAdFactory.create(brand="myfunkybrand")
             self.assertEquals(receiver_buyer.call_count, 1)
             self.assertEquals(receiver_vendor.call_count, 1)
             # modify Ad to correspond => signal to buyer
             ad.brand = "mytoofunkybrand"
             ad.save()
             self.assertEquals(receiver_buyer.call_count, 1)
             self.assertEquals(receiver_vendor.call_count, 1)
             adsearch.delete()
             ad.delete()
Exemple #27
0
 def test_create_update_read_delete_search(self):
     test_ad = TestAdFactory.create()
     # here we build a search ad form
     # create
     location = "SRID%3D900913%3BPOLYGON((2.3886182861327825+48.834761790252024%2C2.2773817138671575+48.837925498723266%2C2.3251035766601262+48.87180983721773%2C2.4023511962890325+48.87293892019383%2C2.3886182861327825+48.834761790252024))"
     request = self.factory.post('/',
                                 data={
                                     'search':
                                     'brand=' + test_ad.brand +
                                     '&location=' + location
                                 })
     user = UserFactory.create()
     request.user = user
     response = views.AdSearchView.as_view(model=TestAd)(request)
     ad_search = AdSearch.objects.all().filter(user=user)[0]
     # update
     request = self.factory.post('/',
                                 data={'search': 'brand=' + test_ad.brand})
     request.user = user
     response = views.AdSearchView.as_view(model=TestAd)(
         request, search_id=ad_search.pk)
     # read
     request = self.factory.get('/')
     request.user = user
     response = views.AdSearchView.as_view(model=TestAd)(
         request, search_id=ad_search.pk)
     not_ad_search_owner_user = UserFactory.create()
     request = self.factory.get('/')
     request.user = not_ad_search_owner_user
     view = views.AdSearchView.as_view(model=TestAd)
     self.assertRaises(Http404, view, request, search_id=ad_search.pk)
     # delete
     request = self.factory.get('/')
     # by non authorized user
     request.user = not_ad_search_owner_user
     view = views.AdSearchDeleteView.as_view()
     self.assertRaises(Http404, view, request, pk=ad_search.pk)
     # by authorized user (owner of ad search)
     request = self.factory.post('/')
     request.user = ad_search.user
     response = views.AdSearchDeleteView.as_view()(request, pk=ad_search.pk)
Exemple #28
0
 def test_owner_update(self):
     test_ad = TestAdFactory.create()
     form_data = {
         'brand': test_ad.brand,
         'location': test_ad.location,
         'user_entered_address': test_ad.user_entered_address,
         'geoads-adpicture-content_type-object_id-TOTAL_FORMS': 4,
         'geoads-adpicture-content_type-object_id-INITIAL_FORMS': 0
     }
     request = self.factory.get('/')
     request.user = test_ad.user
     response = views.AdUpdateView.as_view(model=TestAd,
                                           form_class=TestAdForm)(
                                               request, pk=test_ad.pk)
     self.assertEqual(response.status_code, 200)
     request = self.factory.post('/', data=form_data)
     request.user = test_ad.user
     response = views.AdUpdateView.as_view(model=TestAd,
                                           form_class=TestAdForm)(
                                               request, pk=test_ad.pk)
     self.assertEqual(response.status_code, 301)
Exemple #29
0
    def test_ad_adsearch_and_ads_signals_5(self):
        """
        Mixed case where we change the different fields of ad and addsearch
        """
        with mock_signal_receiver(geoad_new_relevant_ad_for_search) as receiver_buyer:
            with mock_signal_receiver(geoad_new_interested_user) as receiver_vendor:
                ad = TestAdFactory.create(brand="myfunkybrand")
                adsearch = TestAdSearchFactory.create(search="brand=mytoofunkybrand",
                                                      content_type=ContentType.objects.get_for_model(TestAd),
                                                      public=True)

                self.assertEquals(receiver_buyer.call_count, 0)
                self.assertEquals(receiver_vendor.call_count, 0)
                # modify Ad to correspond => signal to buyer
                ad.brand = "mytoofunkybrand"
                ad.save()
                self.assertEquals(receiver_buyer.call_count, 1)
                self.assertEquals(receiver_vendor.call_count, 1)
                # resave Ad to be sure, signal isn't send one more time
                ad.brand = "mytoofunkybrand"
                ad.save()
                self.assertEquals(receiver_buyer.call_count, 1)
                self.assertEquals(receiver_vendor.call_count, 1)
                # modify AdSearch to not correspond
                adsearch.search = "brand=myfunkybrand"
                adsearch.save()
                self.assertEquals(receiver_buyer.call_count, 1)
                self.assertEquals(receiver_vendor.call_count, 1)
                # modify AdSearch to corresond => mail to both
                ad.brand = "myfunkybrand"
                ad.save()
                self.assertEquals(receiver_buyer.call_count, 2)
                self.assertEquals(receiver_vendor.call_count, 2)
                # just change the Ad description to be sure signal is not sent another time
                ad.description = "you must buy it"
                ad.save()
                self.assertEquals(receiver_buyer.call_count, 2)
                self.assertEquals(receiver_vendor.call_count, 2)
                adsearch.delete()
                ad.delete()
Exemple #30
0
 def test_ad_adsearch_and_ads_notifications_5(self):
     # ad Ad, then AdSearch public, not corresponding => no mail
     ad = TestAdFactory.create(brand="myfunkybrand")
     adsearch = TestAdSearchFactory.create(search="brand=mytoofunkybrand",
         content_type=ContentType.objects.get_for_model(TestAd), public=True)
     self.assertEquals(len(mail.outbox), 0)
     # modify Ad to correspond => mail to both
     ad.brand = "mytoofunkybrand"
     ad.save()
     self.assertEquals(len(mail.outbox), 2)
     # resave Ad to be sure, mail isn't send one more time
     ad.brand = "mytoofunkybrand"
     ad.save()
     self.assertEquals(len(mail.outbox), 2)
     # modify AdSearch to not correspond
     adsearch.search = "brand=myfunkybrand"
     adsearch.save()
     self.assertEquals(len(mail.outbox), 2)
     # modify AdSearch to corresond => mail to both
     ad.brand = "myfunkybrand"
     ad.save()
     self.assertEquals(len(mail.outbox), 4)
Exemple #31
0
 def test_read(self):
     test_ad = TestAdFactory.create()
     request = self.factory.get('/')
     response = views.AdDetailView.as_view(model=TestAd)(request,
                                                         pk=test_ad.pk)
Exemple #32
0
 def test_filterset(self):
     ad = TestAdFactory.create(brand="myfunkybrand")
     filterset = TestAdFilterSet({'brand': 'myfunkybrand'})
     self.assertEquals(len(filterset), 1)
     self.assertEquals(filterset[0], ad)
     ad.delete()
Exemple #33
0
 def test_send_message(self):
     test_ad = TestAdFactory.create()
     user = UserFactory.create()
     request = self.factory.post('/', data={'message':'Hi buddy !'})
     request.user = user
     response = views.AdDetailView.as_view(model=TestAd)(request, pk=test_ad.pk)
Exemple #34
0
 def test_read(self):
     test_ad = TestAdFactory.create()
     request = self.factory.get('/')
     response = views.AdDetailView.as_view(model=TestAd)(request, pk=test_ad.pk)
Exemple #35
0
 def test_filterset(self):
     ad = TestAdFactory.create(brand="myfunkybrand")
     filterset = TestAdFilterSet({'brand': 'myfunkybrand'})
     self.assertEquals(len(filterset), 1)
     self.assertEquals(filterset[0], ad)
     ad.delete()