Esempio n. 1
0
 def test_type_of_let_queryset(self):
     lettings = [
         LettingFactory(type_of_let=Letting.TYPE_OF_LET_LONG_TERM),
         LettingFactory(type_of_let=Letting.TYPE_OF_LET_SHORT_TERM)
     ]
     results = Letting.filtered.type_of_let(Letting.TYPE_OF_LET_LONG_TERM)
     self.assertEquals(len(results), 1)
     self.assertEquals(results[0].title, lettings[0].title)
Esempio n. 2
0
 def test_house_share_queryset(self):
     lettings = [
         LettingFactory(house_share=True),
         LettingFactory(house_share=False)
     ]
     results = Letting.filtered.house_share()
     self.assertEquals(len(results), 1)
     self.assertEquals(results[0].title, lettings[0].title)
Esempio n. 3
0
 def test_unfurnished_queryset(self):
     lettings = [
         LettingFactory(furnished=True),
         LettingFactory(furnished=False)
     ]
     results = Letting.filtered.unfurnished()
     self.assertEquals(len(results), 1)
     self.assertEquals(results[0].title, lettings[1].title)
Esempio n. 4
0
 def test_unpublished_queryset(self):
     lettings = [
         LettingFactory(status=Letting.STATUS_CHOICE_ACTIVE),
         LettingFactory(status=Letting.STATUS_CHOICE_INACTIVE)
     ]
     results = Letting.filtered.unpublished()
     self.assertEquals(len(results), 1)
     self.assertEquals(results[0].title, lettings[1].title)
Esempio n. 5
0
 def test_expired_queryset(self):
     lettings = [
         LettingFactory(
             expires_at=datetime.utcnow().replace(tzinfo=pytz.UTC) +
             timedelta(days=30)),
         LettingFactory(
             expires_at=datetime.utcnow().replace(tzinfo=pytz.UTC) +
             timedelta(days=-30))
     ]
     results = Letting.filtered.expired()
     self.assertEquals(len(results), 1)
     self.assertEquals(results[0].title, lettings[1].title)
Esempio n. 6
0
    def test_get_queryset_not_published(self):
        """
         Test that the queryset returned is as expected a LettingQuerySet
         """
        letting = LettingFactory.create(status=Letting.STATUS_CHOICE_INACTIVE)

        request = self.factory.get(reverse('lettings:detail', kwargs={
            'slug': letting.slug
        }))

        request.user = AnonymousUser()

        with self.assertRaises(Http404):
            DetailPageView.as_view()(request, slug=letting.slug)
Esempio n. 7
0
    def test_get_queryset_expired(self):
        """
         Test that the queryset returned is as expected a LettingQuerySet
         """
        expired_date = datetime.utcnow().replace(tzinfo=pytz.utc) - timedelta(days=1)
        letting = LettingFactory.create(expires_at=expired_date)

        request = self.factory.get(reverse('lettings:detail', kwargs={
            'slug': letting.slug
        }))

        request.user = AnonymousUser()

        with self.assertRaises(Http404):
            DetailPageView.as_view()(request, slug=letting.slug)
Esempio n. 8
0
    def test_template_name(self):
        """
        Test that the template name of the view is as expected
        """
        letting = LettingFactory()
        request = self.factory.get(reverse('lettings:detail', kwargs={
            'slug': letting.slug
        }))

        request.user = UserFactory()

        response = DetailPageView.as_view()(request, slug=letting.slug)

        # Check that the correct template is used for the view
        self.assertIn('homes-to-let/detail.html', response.template_name)
Esempio n. 9
0
    def test_get_queryset(self):
        """
         Test that the queryset returned is as expected a LettingQuerySet
         """
        letting = LettingFactory()

        request = self.factory.get(reverse('lettings:detail', kwargs={
            'slug': letting.slug
        }))

        view = super(DetailPageViewTestCase, self).initialize(DetailPageView(), request, kwargs={'slug':letting.slug})

        response = view.get_queryset()

        # Check if response is LettingQuerySet
        self.assertIsInstance(response, LettingQuerySet)
Esempio n. 10
0
    def test_get_context_keys_correct_type(self):
        """
        Test that the context contains required keys in context
        """
        letting = LettingFactory()

        request = self.factory.get(reverse('lettings:detail', kwargs={
            'slug': letting.slug
        }))

        request.user = UserFactory()

        response = DetailPageView.as_view()(request, slug=letting.slug)

        # Check contains contact as LettingContactForm and form as SearchForm
        self.assertIsInstance(response.context_data['contact'], LettingContactForm)
        self.assertIsInstance(response.context_data['form'], SearchForm)
Esempio n. 11
0
    def test_get_context_contains_keys(self):
        """
        Test that the context contains required keys in context
        """
        letting = LettingFactory()
        request = self.factory.get(reverse('lettings:detail', kwargs={
            'slug': letting.slug
        }))

        request.user = UserFactory()

        response = DetailPageView.as_view()(request, slug=letting.slug)

        # Check that the context contains the correct keys
        self.assertIn('contact', response.context_data)
        self.assertIn('favourited', response.context_data)
        self.assertIn('form', response.context_data)
        self.assertIn('google', response.context_data)
        self.assertIn('recaptcha', response.context_data)
Esempio n. 12
0
 def test_string_representation(self):
     sale = LettingFactory()
     self.assertEquals(str(sale), sale.title)