예제 #1
0
 def test_page_failure_mode(self):
     request = construct_dummy_request(
         matchdict={
             'slug': 'cat-or-dog',
             'arg_id_user': 2,
             'relation': 'invalid-relation',
             'arg_id_sys': 16,
         })
     response = reaction(request)
     self.assertIsInstance(response, httpexceptions.HTTPError)
예제 #2
0
 def test_invalid_slug_returns_error(self):
     request = construct_dummy_request(
         matchdict={
             'slug': 'cat-or-doggy_dog',
             'arg_id_user': 2,
             'relation': Relations.UNDERMINE.value,
             'arg_id_sys': 16,
         })
     response = reaction(request)
     self.assertIsInstance(response, httpexceptions.HTTPError)
예제 #3
0
 def test_sys_argument_does_not_belong_to_issue_returns_error(self):
     request = construct_dummy_request(
         matchdict={
             'slug': 'cat-or-dog',
             'arg_id_user': 2,
             'relation': Relations.UNDERMINE.value,
             'arg_id_sys': 45,
         })
     response = reaction(request)
     self.assertIsInstance(response, httpexceptions.HTTPError)
예제 #4
0
    def test_page(self):
        len_db_seen_s1 = DBDiscussionSession.query(SeenStatement).count()
        len_db_votes_s1 = DBDiscussionSession.query(ClickedStatement).count()
        len_db_seen_a1 = DBDiscussionSession.query(SeenArgument).count()
        len_db_votes_a1 = DBDiscussionSession.query(ClickedArgument).count()

        response = reaction(self.default_request)
        verify_dictionary_of_view(response)

        len_db_seen_s2 = DBDiscussionSession.query(SeenStatement).count()
        len_db_votes_s2 = DBDiscussionSession.query(ClickedStatement).count()
        len_db_seen_a2 = DBDiscussionSession.query(SeenArgument).count()
        len_db_votes_a2 = DBDiscussionSession.query(ClickedArgument).count()
        self.assertEqual(len_db_seen_s1,
                         len_db_seen_s2)  # no more cause we are not logged in
        self.assertEqual(len_db_votes_s1, len_db_votes_s2)
        self.assertEqual(len_db_seen_a1, len_db_seen_a2)
        self.assertEqual(len_db_votes_a1, len_db_votes_a2)
예제 #5
0
    def test_page_rep_not_twice(self):
        self.config.testing_securitypolicy(userid='Björn', permissive=True)

        len_db_reputation_initial = DBDiscussionSession.query(
            ReputationHistory).count()
        self.__check_standard_counting(reaction, self.user_bjoern)
        len_db_reputation_after_first_visit = DBDiscussionSession.query(
            ReputationHistory).count()

        response = reaction(self.default_request)
        self.assertIsInstance(response, dict)
        len_db_reputation_after_second_visit = DBDiscussionSession.query(
            ReputationHistory).count()

        self.assertGreater(len_db_reputation_after_first_visit,
                           len_db_reputation_initial)
        self.assertEqual(len_db_reputation_after_first_visit,
                         len_db_reputation_after_second_visit,
                         'No rep on second visit')