コード例 #1
0
ファイル: tests.py プロジェクト: karlw00t/qasoft
    def test_basic_addition(self):
        user = User.objects.all()[0]
        point = Point()
        point.fromuser = user
        point.save()

        question = Question();
        question.user = user
        question.title = "hi"
        question.slug = 'something'
        question.text = 'else'
        question.save()
        question.points.add(point)
        question.save()
        
        self.assertEquals(1, question.total_points())
コード例 #2
0
ファイル: tests.py プロジェクト: karlw00t/qasoft
    def test_user_points(self):
        josh = User.objects.all()[0]

        question = Question();
        question.user = josh
        question.title = "hi"
        question.slug = 'something'
        question.text = 'else'
        question.save()

        point = Point()
        point.fromuser = josh
        point.save()
        question.points.add(point)

        user = User()
        user.save()
        point = Point()
        point.fromuser = user
        point.save()
        question.points.add(point)

        self.assertEquals(2, userPoint(josh))
コード例 #3
0
ファイル: tests.py プロジェクト: karlw00t/qasoft
    def test_add_point_to_question(self):
        self.client.login(username='******', password='******')
        user = User.objects.all()[0]

        question = Question();
        question.user = user
        question.title = "hi"
        question.slug = 'something'
        question.text = 'else'
        question.save()

        response = self.client.post('/ajax/forum/upvote_question.json', {'question_pk': question.pk})
        json_response = json.loads(response.content)
        self.assertTrue(json_response['success'])
        self.assertTrue(json_response['data']['delta'], 1)
        self.assertEquals(1, Question.objects.all().count())
        
        response = self.client.post('/ajax/forum/upvote_question.json', {'question_pk': question.pk})
        json_response = json.loads(response.content)
        self.assertTrue(json_response['success'])
        self.assertTrue(json_response['data']['delta'], -1)
        print Point.objects.all()
        self.assertEquals(0, Point.objects.all().count())