def test_passing_view(self): request = dummy_request(self.session) request_list = RequestQueryset(request).get_requests() request_list_dict = parse_query_to_dict(request_list, 'requests') info = get_requests(request) self.assertEqual(info['requests'][0]['session_key'], request_list_dict['requests'][0]['session_key'])
def test_passing_view(self): request = dummy_request(self.session) session_query = SessionQueryset(request).get_sessions() session_dict = parse_query_to_dict(session_query, 'session') request.matchdict['session_key'] = session_dict['session'][0][ 'session_key'] info = get_session(request) self.assertEqual(info['session'][0]['browser_name'], 'Firefox')
def test_passing_view(self): request = dummy_request(self.session) session_list = SessionQueryset(request).get_sessions() session_dict = parse_query_to_dict(session_list, 'session') request.matchdict['session_key'] = session_dict['session'][0][ 'session_key'] info = get_requests_by_session(request) self.assertEqual(len(info['request']), 1) self.assertEqual(info['request'][0]['session_key'], session_dict['session'][0]['session_key'])
def get_sessions(request): """ Get all sessions of db and pass to api as response :param request: :return: list of sessions """ session_query = SessionQueryset(request).get_sessions() if session_query: return parse_query_to_dict(session_query, 'sessions') return Response(db_err_msg, content_type='text/plain', status=500)