from django.test import TestCase

from studygroups.models import Course
from .community_feedback import calculate_course_ratings
from .community_feedback import calculate_course_tagdorsements


class TestCommunityFeedback(TestCase):
    fixtures = ['test_courses.json', 'test_studygroups.json', 'test_applications.json', 'test_survey_responses.json']

    def test_calculate_course_ratings(self):
        course = Course.objects.get(pk=3)

        self.assertEqual(course.overall_rating, 0)
        self.assertEqual(course.rating_step_counts, "{}")
        self.assertEqual(course.total_ratings, 0)

        calculate_course_ratings(course)

        expected_rating_step_counts = '{"5": 2, "4": 1, "3": 0, "2": 0, "1": 0}'

        self.assertEqual(course.overall_rating, 4.67)
        self.assertEqual(course.rating_step_counts, expected_rating_step_counts)
        self.assertEqual(course.total_ratings, 3)

    def test_calculate_course_tagdorsements(self):
        course = Course.objects.get(pk=3)

        self.assertEqual(course.tagdorsement_counts, "{}")
        self.assertEqual(course.tagdorsements, "")
        self.assertEqual(course.total_reviewers, 0)

        calculate_course_tagdorsements(course)

        self.assertEqual(course.tagdorsement_counts, '{"Easy to use": 1, "Good for first time facilitators": 0, "Great for beginners": 1, "Engaging material": 1, "Led to great discussions": 1}')
        self.assertEqual(course.tagdorsements, 'Easy to use, Great for beginners, Engaging material, Led to great discussions')
        self.assertEqual(course.total_reviewers, 1)

@@ -126,71 +126,8 @@
 ngs%0A
-from .community_feedback import calculate_course_tagdorsements%0A
 %0A%0Acl
@@ -844,684 +844,4 @@
 3)%0A%0A
-    def test_calculate_course_tagdorsements(self):%0A        course = Course.objects.get(pk=3)%0A%0A        self.assertEqual(course.tagdorsement_counts, %22%7B%7D%22)%0A        self.assertEqual(course.tagdorsements, %22%22)%0A        self.assertEqual(course.total_reviewers, 0)%0A%0A        calculate_course_tagdorsements(course)%0A%0A        self.assertEqual(course.tagdorsement_counts, '%7B%22Easy to use%22: 1, %22Good for first time facilitators%22: 0, %22Great for beginners%22: 1, %22Engaging material%22: 1, %22Led to great discussions%22: 1%7D')%0A        self.assertEqual(course.tagdorsements, 'Easy to use, Great for beginners, Engaging material, Led to great discussions')%0A        self.assertEqual(course.total_reviewers, 1)%0A

Remove tagdorsements from survey tests