def test_wrong_relation(self): request = construct_dummy_request( matchdict={ 'slug': 'cat-or-dog', 'argument_id': 4, 'attitude': Attitudes.AGREE.value, 'relation': 'i am groot', }) response = justify_argument(request) self.assertIsInstance(response, httpexceptions.HTTPError)
def test_justify_argument_page_count_clicked_once(self): DBDiscussionSession.query(Argument).get(1).set_disabled(True) transaction.commit() request = construct_dummy_request( matchdict={ 'slug': 'cat-or-dog', 'argument_id': 1, 'attitude': Attitudes.AGREE.value, 'relation': Relations.UNDERMINE.value, }) response = justify_argument(request) self.assertIsInstance(response, httpexceptions.HTTPError)
def test_justify_argument_page_no_rep(self): vote_dict = get_meta_clicks() len_db_reputation1 = DBDiscussionSession.query( ReputationHistory).count() request = construct_dummy_request( matchdict={ 'slug': 'cat-or-dog', 'argument_id': 4, 'attitude': Attitudes.AGREE.value, 'relation': Relations.UNDERMINE.value, }) response = justify_argument(request) self.assertNotIsInstance(response, httpexceptions.HTTPError) verify_dictionary_of_view(response) len_db_reputation2 = DBDiscussionSession.query( ReputationHistory).count() check_meta_clicks(self, vote_dict) self.assertEqual(len_db_reputation1, len_db_reputation2)
def __call_function_and_count_seen_clicked_arguments(self): request = construct_dummy_request( matchdict={ 'slug': 'cat-or-dog', 'argument_id': 15, 'attitude': Attitudes.DISAGREE.value, 'relation': Relations.UNDERCUT.value, }) seen_arguments_before = DBDiscussionSession.query(SeenArgument).count() clicked_arguments_before = DBDiscussionSession.query( ClickedArgument).count() response = justify_argument(request) self.assertNotIsInstance(response, httpexceptions.HTTPError) verify_dictionary_of_view(response) self.assertGreater( DBDiscussionSession.query(SeenArgument).count(), seen_arguments_before) self.assertEqual( DBDiscussionSession.query(ClickedArgument).count(), clicked_arguments_before)