Example #1
0
	def test_add_post(self):
		self.test_healer.ratings_1_star = 0
		self.test_healer.ratings_2_star = 0
		self.test_healer.ratings_3_star = 2
		self.test_healer.ratings_4_star = 2
		self.test_healer.ratings_5_star = 2
		self.test_healer.ratings_average = 4
		self.test_healer.save()

		response = self.client.post(
			reverse('review_form', args=[self.username]),
			{'title': 'Test'*2, 'review': 'Test'*5, 'rating': 5})

		self.assertEqual(response.status_code, 302)

		review = Review.objects.get(title='Test'*2, review='Test'*5)
		self.assertEqual(review.reviewer, self.test_client)
		self.assertEqual(review.healer, self.test_healer)
		self.assertEqual(review.rating, 5)

		self.test_healer = Healer.objects.get(pk=1)
		self.assertEqual(self.test_healer.ratings_5_star, 3)
		self.assertEqual(
			'%.2f' % self.test_healer.ratings_average,
			'%.2f' % (float(29)/7))

		self.assertEqual(count_emails(), 1)
		self.assertEqual(
			get_email().subject,
			'You have a new review on HealerSource!')
Example #2
0
	def test_single(self):
		create_appointment(
			healer=self.test_healer,
			client=self.test_client,
			start_date=self.start.date(),
			end_date=self.end.date(),
			start_time=get_minutes(self.start),
			end_time=get_minutes(self.end),
			confirmed=True,
			treatment_length=self.treatment_length)
		args = []
		opts = {}
		call_command('send_review_reminders', *args, **opts)

		self.assertEqual(count_emails(), 1)
Example #3
0
	def test_repeat(self):
		self.start = create_test_time() - timedelta(days=4)
		self.end = self.start + timedelta(hours=2)
		create_appointment(
			healer=self.test_healer,
			client=self.test_client,
			start_date=self.start.date(),
			start_time=get_minutes(self.start),
			end_time=get_minutes(self.end),
			confirmed=True,
			repeat_period=rrule.DAILY,
			repeat_every=3,
			treatment_length=self.treatment_length)
		args = []
		opts = {}
		call_command('send_review_reminders', *args, **opts)

		self.assertEqual(count_emails(), 1)
Example #4
0
	def test_review_permission(self):
		self.test_healer.review_permission = Healer.VISIBLE_DISABLED
		self.test_healer.save()

		create_appointment(
			healer=self.test_healer,
			client=self.test_client,
			start_date=self.start.date(),
			end_date=self.end.date(),
			start_time=get_minutes(self.start),
			end_time=get_minutes(self.end),
			confirmed=True,
			treatment_length=self.treatment_length)
		args = []
		opts = {}
		call_command('send_review_reminders', *args, **opts)

		self.assertEqual(count_emails(), 0)
Example #5
0
    def test_invite_existing_provider(self):
        provider = Healer.objects.get(pk=3)
        message = 'test message'
        data = {
            'providers': provider.id,
            'message': message,
            'invite_type': 'client',
            'invite_provider_recommend': 'true',
            'postcard_background': PostcardBackgroundField().choices[0][0]
        }
        response = self.client.post(reverse('invite_postcard'), data)

        self.assertEqual(response.status_code, 200)
        self.assertFalse(SiteJoinInvitation.objects.all().count())
        self.assertFalse(count_emails())
        self.assertContains(response, 'We\'ve added them to your Clients')
        self.assertEqual(
            Clients.objects.filter(from_user=self.test_healer.user,
                                   to_user=provider.user).count(), 1)
Example #6
0
	def test_review_exists(self):
		Review.objects.create(
			reviewer=self.test_client,
			healer=self.test_healer,
			title="Test",
			review="Test",
			rating=4)
		create_appointment(
			healer=self.test_healer,
			client=self.test_client,
			start_date=self.start.date(),
			end_date=self.end.date(),
			start_time=get_minutes(self.start),
			end_time=get_minutes(self.end),
			confirmed=True,
			treatment_length=self.treatment_length)
		args = []
		opts = {}
		call_command('send_review_reminders', *args, **opts)

		self.assertEqual(count_emails(), 0)
Example #7
0
	def test_edit_post(self):
		review = Review.objects.create(
			healer=self.test_healer,
			reviewer=self.test_client,
			title='test',
			review='test',
			rating=4)

		self.test_healer.ratings_1_star = 0
		self.test_healer.ratings_2_star = 0
		self.test_healer.ratings_3_star = 2
		self.test_healer.ratings_4_star = 2
		self.test_healer.ratings_5_star = 2
		self.test_healer.ratings_average = 4
		self.test_healer.save()

		response = self.client.post(
			reverse('review_form', args=[self.username]),
			{'title': 'Test1'*2, 'review': 'Test1'*5, 'rating': 5})

		self.assertEqual(response.status_code, 302)

		review = Review.objects.get(pk=review.pk)
		self.assertEqual(review.reviewer, self.test_client)
		self.assertEqual(review.healer, self.test_healer)
		self.assertEqual(review.rating, 5)
		self.assertEqual(review.title, 'Test1'*2)

		self.test_healer = Healer.objects.get(pk=1)
		self.assertEqual(self.test_healer.ratings_4_star, 1)
		self.assertEqual(self.test_healer.ratings_5_star, 3)
		self.assertEqual(
			'%.2f' % self.test_healer.ratings_average,
			'%.2f' % (float(25)/6))

		self.assertEqual(count_emails(), 0)