def test_get_path_of_user(self): response = lib.get_path_of_user('http://localhost:4284/', '?history=/attitude/2', self.issue_elektroautos) self.assertEqual(len(response), 0) path = [ '?history=/attitude/2-/justify/2/agree', '?history=/attitude/2-/justify/2/agree-/reaction/2/undercut/18-/justify/2/agree', '?history=/attitude/2-/justify/2/agree-/reaction/12/undercut/13-/justify/13/agree/undercut' ] for p in path: response = lib.get_path_of_user('http://localhost:4284/', p, self.issue_elektroautos) self.assertNotEqual(len(response), 0)
def test_get_path_of_user(self): db_issue = DBDiscussionSession.query(Issue).get(4) response = lib.get_path_of_user('http://localhost:4284/', '?history=/attitude/2', db_issue) self.assertEqual(0, len(response)) path = [ '?history=/attitude/2-/justify/2/agree', '?history=/attitude/2-/justify/2/agree-/reaction/2/undercut/18-/justify/2/agree', '?history=/attitude/2-/justify/2/agree-/reaction/12/undercut/13-/justify/13/agree/undercut' ] for p in path: response = lib.get_path_of_user('http://localhost:4284/', p, db_issue) self.assertNotEqual(0, len(response))
def get_d3_partial_dump(request): LOG.debug("Create partial d3 dump. %s", request.json_body) path = request.validated['path'] uid = request.validated['uid'] is_argument = request.validated['is_argument'] db_issue = request.validated['issue'] return_dict = { 'type': 'partial' } if is_argument: graph, error = get_partial_graph_for_argument(uid, db_issue) else: graph, error = get_partial_graph_for_statement(uid, db_issue, path) if not error: return_dict.update(graph) return_dict.update({'node_opinion_factors': get_opinion_data(db_issue)}) return_dict.update({'path': get_path_of_user(request.application_url, path, db_issue)}) return_dict.update({'error': ''}) else: # gets called if the data itself is malicious ui_locales = get_language_from_cookie(request) _t = Translator(ui_locales) error = _t.get(_.internalKeyError) return_dict = { 'error': error } return return_dict
def get_d3_complete_dump(request): LOG.debug("Creating a complete d3 dump. %s", request.json_body) path = request.json_body.get('path', '') db_issue = request.validated['issue'] graph, error = get_d3_data(db_issue) return_dict = graph return_dict.update({'type': 'complete'}) if not error: return_dict.update({'path': get_path_of_user(request.application_url, path, db_issue)}) return_dict.update({'error': ''}) else: # gets called if the data itself is malicious ui_locales = get_language_from_cookie(request) _t = Translator(ui_locales) error = _t.get(_.internalKeyError) return_dict = {'error': error} return return_dict