Ejemplo n.º 1
0
    def test_attack_statement_page(self):
        self.config.testing_securitypolicy(userid='Tobias', permissive=True)

        len_db_seen1 = DBDiscussionSession.query(SeenStatement).count()
        len_db_vote1 = DBDiscussionSession.query(ClickedStatement).filter(
            ClickedStatement.is_valid == True,
            ClickedStatement.is_up_vote == False).count()
        request = construct_dummy_request(
            matchdict={
                'slug': 'cat-or-dog',
                'statement_id': 2,
                'attitude': Attitudes.DISAGREE.value,
            })
        response = justify_statement(request)
        self.assertNotIsInstance(response, httpexceptions.HTTPError)
        transaction.commit()
        verify_dictionary_of_view(response)
        len_db_seen2 = DBDiscussionSession.query(SeenStatement).count()
        len_db_vote2 = DBDiscussionSession.query(ClickedStatement).filter(
            ClickedStatement.is_valid == True,
            ClickedStatement.is_up_vote == False).count()

        # minus 1 for 'none of the above'
        count = sum(
            [len(el['premises']) for el in response['items']['elements']])
        self.assertEqual(len_db_seen1 + count, len_db_seen2)
        self.assertEqual(len_db_vote1 + 1, len_db_vote2)
        clear_seen_by_of('Tobias')
        clear_clicks_of('Tobias')
Ejemplo n.º 2
0
 def test_wrong_slug(self):
     request = construct_dummy_request(
         matchdict={
             'slug': 'kitty-or-doggy-is-a-wrong-slug',
             'statement_id': 2,
             'attitude': Attitudes.AGREE.value,
         })
     response = justify_statement(request)
     self.assertIsInstance(response, httpexceptions.HTTPError)
Ejemplo n.º 3
0
 def test_stmt_or_arg_id_does_not_belong_to_issue(self):
     request = construct_dummy_request(
         matchdict={
             'slug': 'cat-or-dog',
             'statement_id': 40,
             'attitude': Attitudes.AGREE.value,
         })
     response = justify_statement(request)
     self.assertIsInstance(response, httpexceptions.HTTPError)
Ejemplo n.º 4
0
 def test_wrong_attitude(self):
     request = construct_dummy_request(
         matchdict={
             'slug': 'cat-or-dog',
             'statement_id': 2,
             'attitude': 'not-a-valid-attitude',
         })
     response = justify_statement(request)
     self.assertIsInstance(response, httpexceptions.HTTPError)
Ejemplo n.º 5
0
 def test_justify_statement_page(self):
     vote_dict = get_meta_clicks()
     request = construct_dummy_request(
         matchdict={
             'slug': 'cat-or-dog',
             'statement_id': 2,
             'attitude': Attitudes.AGREE.value,
         })
     response = justify_statement(request)
     self.assertNotIsInstance(response, httpexceptions.HTTPError)
     verify_dictionary_of_view(response)
     check_meta_clicks(self, vote_dict)