def test_fetch_from_non_set_cache(self): """Test if a error is raised when the cache was not set""" phab = Phabricator(PHABRICATOR_URL, 'AAAA') with self.assertRaises(CacheError): _ = [task for task in phab.fetch_from_cache()]
def test_fetch_empty(self): """Test if nothing is returnerd when there are no tasks""" http_requests = setup_http_server() from_date = datetime.datetime(2017, 1, 1, 0, 0, 0) phab = Phabricator(PHABRICATOR_URL, 'AAAA') tasks = [task for task in phab.fetch(from_date=from_date)] self.assertEqual(len(tasks), 0) # Check requests expected = { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'attachments' : {'projects' : True}, 'constraints' : {'modifiedStart' : 1483228800}, 'order' : 'outdated' } } self.assertEqual(len(http_requests), 1) rparams = http_requests[0].parsed_body rparams['params'] = json.loads(rparams['params'][0]) self.assertDictEqual(rparams, expected)
def test_fetch_empty(self): """Test if nothing is returnerd when there are no tasks""" http_requests = setup_http_server() from_date = datetime.datetime(2017, 1, 1, 0, 0, 0) phab = Phabricator(PHABRICATOR_URL, 'AAAA') tasks = [task for task in phab.fetch(from_date=from_date)] self.assertEqual(len(tasks), 0) # Check requests expected = { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'attachments' : {'projects' : True}, 'constraints' : [{'modifiedStart' : 1483228800}], 'order' : 'outdated' } } self.assertEqual(len(http_requests), 1) rparams = http_requests[0].parsed_body rparams['params'] = json.loads(rparams['params'][0]) self.assertDictEqual(rparams, expected)
def test_fetch_from_empty_cache(self): """Test if there are not any task returned when the cache is empty""" cache = Cache(self.tmp_path) phab = Phabricator(PHABRICATOR_URL, 'AAAA', cache=cache) cached_tasks = [task for task in phab.fetch_from_cache()] self.assertEqual(len(cached_tasks), 0)
def test_fetch_from_cache(self): """Test whether the cache works""" http_requests = setup_http_server() # First, we fetch the tasks from the server, # storing them in a cache cache = Cache(self.tmp_path) phab = Phabricator(PHABRICATOR_URL, 'AAAA', cache=cache) tasks = [task for task in phab.fetch()] self.assertEqual(len(http_requests), 12) # Now, we get the tasks from the cache. # The tasks should be the same and there won't be # any new request to the server cached_tasks = [task for task in phab.fetch_from_cache()] self.assertEqual(len(cached_tasks), len(tasks)) expected = [(69, 16, 0, 'jdoe', 'jdoe', '1b4c15d26068efcae83cd920bcada6003d2c4a6c', 1462306027.0), (73, 20, 0, 'jdoe', 'janesmith', '5487fc704f2d3c4e83ab0cd065512a181c1726cc', 1462464642.0), (78, 17, 0, 'jdoe', None, 'fa971157c4d0155652f94b673866abd83b929b27', 1462792338.0), (296, 18, 2, 'jane', 'jrae', 'e8fa3e4a4381d6fea3bcf5c848f599b87e7dc4a6', 1467196707.0)] self.assertEqual(len(cached_tasks), len(expected)) for x in range(len(cached_tasks)): task = cached_tasks[x] expc = expected[x] self.assertEqual(task['data']['id'], expc[0]) self.assertEqual(len(task['data']['transactions']), expc[1]) self.assertEqual(len(task['data']['projects']), expc[2]) self.assertEqual(task['data']['fields']['authorData']['userName'], expc[3]) # Check owner data; when it is null owner is not included if not expc[4]: self.assertNotIn('ownerData', task['data']['fields']) else: self.assertEqual( task['data']['fields']['ownerData']['userName'], expc[4]) self.assertEqual(task['uuid'], expc[5]) self.assertEqual(task['origin'], PHABRICATOR_URL) self.assertEqual(task['updated_on'], expc[6]) self.assertEqual(task['category'], 'task') self.assertEqual(task['tag'], PHABRICATOR_URL) # Compare chached and fetched task self.assertDictEqual(task['data'], tasks[x]['data']) # No more requests were sent self.assertEqual(len(http_requests), 12)
def test_fetch_from_cache(self): """Test whether the cache works""" http_requests = setup_http_server() # First, we fetch the tasks from the server, # storing them in a cache cache = Cache(self.tmp_path) phab = Phabricator(PHABRICATOR_URL, 'AAAA', cache=cache) tasks = [task for task in phab.fetch()] self.assertEqual(len(http_requests), 12) # Now, we get the tasks from the cache. # The tasks should be the same and there won't be # any new request to the server cached_tasks = [task for task in phab.fetch_from_cache()] self.assertEqual(len(cached_tasks), len(tasks)) expected = [(69, 16, 0, 'jdoe', 'jdoe', '1b4c15d26068efcae83cd920bcada6003d2c4a6c', 1462306027.0), (73, 20, 0, 'jdoe', 'janesmith', '5487fc704f2d3c4e83ab0cd065512a181c1726cc', 1462464642.0), (78, 17, 0, 'jdoe', None, 'fa971157c4d0155652f94b673866abd83b929b27', 1462792338.0), (296, 18, 2, 'jane', 'jrae','e8fa3e4a4381d6fea3bcf5c848f599b87e7dc4a6', 1467196707.0)] self.assertEqual(len(cached_tasks), len(expected)) for x in range(len(cached_tasks)): task = cached_tasks[x] expc = expected[x] self.assertEqual(task['data']['id'], expc[0]) self.assertEqual(len(task['data']['transactions']), expc[1]) self.assertEqual(len(task['data']['projects']), expc[2]) self.assertEqual(task['data']['fields']['authorData']['userName'], expc[3]) # Check owner data; when it is null owner is not included if not expc[4]: self.assertNotIn('ownerData', task['data']['fields']) else: self.assertEqual(task['data']['fields']['ownerData']['userName'], expc[4]) self.assertEqual(task['uuid'], expc[5]) self.assertEqual(task['origin'], PHABRICATOR_URL) self.assertEqual(task['updated_on'], expc[6]) self.assertEqual(task['category'], 'task') self.assertEqual(task['tag'], PHABRICATOR_URL) # Compare chached and fetched task self.assertDictEqual(task['data'], tasks[x]['data']) # No more requests were sent self.assertEqual(len(http_requests), 12)
def test_initialization(self): """Test whether attributes are initializated""" phab = Phabricator(PHABRICATOR_URL, 'AAAA', origin='test') self.assertEqual(phab.url, PHABRICATOR_URL) self.assertEqual(phab.origin, 'test') self.assertIsInstance(phab.client, ConduitClient) # When origin is empty or None it will be set to # the value in url phab = Phabricator(PHABRICATOR_URL, 'AAAA') self.assertEqual(phab.url, PHABRICATOR_URL) self.assertEqual(phab.origin, PHABRICATOR_URL) phab = Phabricator(PHABRICATOR_URL, 'AAAA', origin='') self.assertEqual(phab.url, PHABRICATOR_URL) self.assertEqual(phab.origin, PHABRICATOR_URL)
def test_parse_tasks(self): """Test if it parses a tasks stream""" raw_json = read_file('data/phabricator/phabricator_tasks.json') tasks = Phabricator.parse_tasks(raw_json) results = [task for task in tasks] self.assertEqual(len(results), 3) self.assertEqual(results[0]['id'], 69) self.assertEqual(results[1]['id'], 73) self.assertEqual(results[2]['id'], 78) # Parse a file without results raw_json = read_file('data/phabricator/phabricator_tasks_empty.json') tasks = Phabricator.parse_tasks(raw_json) results = [task for task in tasks] self.assertEqual(len(results), 0)
def test_parse_tasks_transactions(self): """Test if it parses a tasks transactions stream""" raw_json = read_file('data/phabricator/phabricator_transactions.json') results = Phabricator.parse_tasks_transactions(raw_json) self.assertEqual(len(results), 3) self.assertEqual(len(results['69']), 16) self.assertEqual(len(results['73']), 20) self.assertEqual(len(results['78']), 17)
def test_parse_phids(self): """Test if it parses a phids stream""" raw_json = read_file('data/phabricator/phabricator_phids.json') phids = Phabricator.parse_phids(raw_json) results = [phid for phid in phids] results.sort(key=lambda x: x['fullName']) self.assertEqual(len(results), 2) self.assertEqual(results[0]['fullName'], 'Herald') self.assertEqual(results[1]['fullName'], 'Mock')
def test_parse_users(self): """Test if it parses a users stream""" raw_json = read_file('data/phabricator/phabricator_users.json') users = Phabricator.parse_users(raw_json) results = [user for user in users] self.assertEqual(len(results), 4) self.assertEqual(results[0]['userName'], 'jrae') self.assertEqual(results[1]['userName'], 'jsmith') self.assertEqual(results[2]['userName'], 'jdoe') self.assertEqual(results[3]['userName'], 'jane')
def test_has_resuming(self): """Test if it returns True when has_resuming is called""" self.assertEqual(Phabricator.has_resuming(), True)
def test_fetch(self): """Test whether it fetches a set of tasks""" http_requests = setup_http_server() phab = Phabricator(PHABRICATOR_URL, 'AAAA') tasks = [task for task in phab.fetch()] expected = [(69, 16, 'jdoe', 'jdoe', '1b4c15d26068efcae83cd920bcada6003d2c4a6c', 1462306027.0), (73, 20, 'jdoe', 'janesmith', '5487fc704f2d3c4e83ab0cd065512a181c1726cc', 1462464642.0), (78, 17, 'jdoe', None, 'fa971157c4d0155652f94b673866abd83b929b27', 1462792338.0), (296, 18, 'jane', 'jrae','e8fa3e4a4381d6fea3bcf5c848f599b87e7dc4a6', 1467196707.0)] self.assertEqual(len(tasks), len(expected)) for x in range(len(tasks)): task = tasks[x] expc = expected[x] self.assertEqual(task['data']['id'], expc[0]) self.assertEqual(len(task['data']['transactions']), expc[1]) self.assertEqual(task['data']['fields']['authorData']['userName'], expc[2]) # Check owner data; when it is null owner is not included if not expc[3]: self.assertNotIn('ownerData', task['data']['fields']) else: self.assertEqual(task['data']['fields']['ownerData']['userName'], expc[3]) self.assertEqual(task['uuid'], expc[4]) self.assertEqual(task['origin'], PHABRICATOR_URL) self.assertEqual(task['updated_on'], expc[5]) self.assertEqual(task['category'], 'task') self.assertEqual(task['tag'], PHABRICATOR_URL) # Check some authors info on transactions trans = tasks[0]['data']['transactions'] self.assertEqual(trans[0]['authorData']['userName'], 'jdoe') self.assertEqual(trans[15]['authorData']['userName'], 'jdoe') trans = tasks[3]['data']['transactions'] self.assertEqual(trans[0]['authorData']['userName'], 'jrae') self.assertEqual(trans[15]['authorData']['userName'], 'jane') self.assertEqual(trans[16]['authorData']['name'], 'Herald') # Check some info about projects prjs = tasks[0]['data']['projects'] self.assertEqual(len(prjs), 0) prjs = tasks[3]['data']['projects'] self.assertEqual(len(prjs), 2) self.assertEqual(prjs[0]['phid'], 'PHID-PROJ-zi2ndtoy3fh5pnbqzfdo') self.assertEqual(prjs[0]['name'], 'Team: Devel') self.assertEqual(prjs[1]['phid'], 'PHID-PROJ-2qnt6thbrd7qnx5bitzy') self.assertEqual(prjs[1]['name'], 'Bug report') # Check requests expected = [{ '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'attachments' : {'projects' : True}, 'constraints' : {'modifiedStart' : 1}, 'order' : 'outdated' } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'ids' : [69, 73, 78] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-USER-2uk52xorcqb6sjvp467y'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-USER-bjxhrstz5fb5gkrojmev'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-USER-mjr7pnwpg6slsnjcqki7'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'after' : '335', 'attachments' : {'projects' : True}, 'constraints' : {'modifiedStart' : 1}, 'order' : 'outdated' } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'ids' : [296] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-USER-pr5fcxy4xk5ofqsfqcfc'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-USER-ojtcpympsmwenszuef7p'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-APPS-PhabricatorHeraldApplication'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-PROJ-zi2ndtoy3fh5pnbqzfdo'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-PROJ-2qnt6thbrd7qnx5bitzy'] } }] self.assertEqual(len(http_requests), len(expected)) for i in range(len(expected)): rparams = http_requests[i].parsed_body rparams['params'] = json.loads(rparams['params'][0]) self.assertDictEqual(rparams, expected[i])
def test_fetch_from_date(self): """Test wether if fetches a set of tasks from the given date""" http_requests = setup_http_server() from_date = datetime.datetime(2016, 6, 29, 0, 0, 0) phab = Phabricator(PHABRICATOR_URL, 'AAAA') tasks = [task for task in phab.fetch(from_date=from_date)] self.assertEqual(len(tasks), 1) task = tasks[0] self.assertEqual(task['data']['id'], 296) self.assertEqual(task['data']['fields']['authorData']['userName'], 'jane') self.assertEqual(task['data']['fields']['ownerData']['userName'], 'jrae') self.assertEqual(len(task['data']['transactions']), 18) self.assertEqual(task['uuid'], 'e8fa3e4a4381d6fea3bcf5c848f599b87e7dc4a6') self.assertEqual(task['origin'], PHABRICATOR_URL) self.assertEqual(task['updated_on'], 1467196707.0) self.assertEqual(task['category'], 'task') self.assertEqual(task['tag'], PHABRICATOR_URL) # Check requests expected = [{ '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'attachments' : {'projects' : True}, 'constraints' : [{'modifiedStart' : 1467158400}], 'order' : 'outdated' } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'ids' : [296] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-USER-pr5fcxy4xk5ofqsfqcfc'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-USER-ojtcpympsmwenszuef7p'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-APPS-PhabricatorHeraldApplication'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-PROJ-zi2ndtoy3fh5pnbqzfdo'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-PROJ-2qnt6thbrd7qnx5bitzy'] } }] self.assertEqual(len(http_requests), len(expected)) for i in range(len(expected)): rparams = http_requests[i].parsed_body rparams['params'] = json.loads(rparams['params'][0]) self.assertDictEqual(rparams, expected[i])
def test_fetch(self): """Test whether it fetches a set of tasks""" http_requests = setup_http_server() phab = Phabricator(PHABRICATOR_URL, 'AAAA') tasks = [task for task in phab.fetch()] expected = [(69, 16, 'jdoe', 'jdoe', '1b4c15d26068efcae83cd920bcada6003d2c4a6c', 1462306027.0), (73, 20, 'jdoe', 'janesmith', '5487fc704f2d3c4e83ab0cd065512a181c1726cc', 1462464642.0), (78, 17, 'jdoe', None, 'fa971157c4d0155652f94b673866abd83b929b27', 1462792338.0), (296, 18, 'jane', 'jrae','e8fa3e4a4381d6fea3bcf5c848f599b87e7dc4a6', 1467196707.0)] self.assertEqual(len(tasks), len(expected)) for x in range(len(tasks)): task = tasks[x] expc = expected[x] self.assertEqual(task['data']['id'], expc[0]) self.assertEqual(len(task['data']['transactions']), expc[1]) self.assertEqual(task['data']['fields']['authorData']['userName'], expc[2]) # Check owner data; when it is null owner is not included if not expc[3]: self.assertNotIn('ownerData', task['data']['fields']) else: self.assertEqual(task['data']['fields']['ownerData']['userName'], expc[3]) self.assertEqual(task['uuid'], expc[4]) self.assertEqual(task['origin'], PHABRICATOR_URL) self.assertEqual(task['updated_on'], expc[5]) self.assertEqual(task['category'], 'task') self.assertEqual(task['tag'], PHABRICATOR_URL) # Check some authors info on transactions trans = tasks[0]['data']['transactions'] self.assertEqual(trans[0]['authorData']['userName'], 'jdoe') self.assertEqual(trans[15]['authorData']['userName'], 'jdoe') trans = tasks[3]['data']['transactions'] self.assertEqual(trans[0]['authorData']['userName'], 'jrae') self.assertEqual(trans[15]['authorData']['userName'], 'jane') self.assertEqual(trans[16]['authorData']['name'], 'Herald') # Check some info about projects prjs = tasks[0]['data']['projects'] self.assertEqual(len(prjs), 0) prjs = tasks[3]['data']['projects'] self.assertEqual(len(prjs), 2) self.assertEqual(prjs[0]['phid'], 'PHID-PROJ-zi2ndtoy3fh5pnbqzfdo') self.assertEqual(prjs[0]['name'], 'Team: Devel') self.assertEqual(prjs[1]['phid'], 'PHID-PROJ-2qnt6thbrd7qnx5bitzy') self.assertEqual(prjs[1]['name'], 'Bug report') # Check requests expected = [{ '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'attachments' : {'projects' : True}, 'constraints' : [{'modifiedStart' : 0}], 'order' : 'outdated' } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'ids' : [69, 73, 78] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-USER-2uk52xorcqb6sjvp467y'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-USER-bjxhrstz5fb5gkrojmev'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-USER-mjr7pnwpg6slsnjcqki7'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'after' : '335', 'attachments' : {'projects' : True}, 'constraints' : [{'modifiedStart' : 0}], 'order' : 'outdated' } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'ids' : [296] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-USER-pr5fcxy4xk5ofqsfqcfc'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-USER-ojtcpympsmwenszuef7p'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-APPS-PhabricatorHeraldApplication'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-PROJ-zi2ndtoy3fh5pnbqzfdo'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-PROJ-2qnt6thbrd7qnx5bitzy'] } }] self.assertEqual(len(http_requests), len(expected)) for i in range(len(expected)): rparams = http_requests[i].parsed_body rparams['params'] = json.loads(rparams['params'][0]) self.assertDictEqual(rparams, expected[i])
def test_fetch_from_date(self): """Test wether if fetches a set of tasks from the given date""" http_requests = setup_http_server() from_date = datetime.datetime(2016, 6, 29, 0, 0, 0) phab = Phabricator(PHABRICATOR_URL, 'AAAA') tasks = [task for task in phab.fetch(from_date=from_date)] self.assertEqual(len(tasks), 1) task = tasks[0] self.assertEqual(task['data']['id'], 296) self.assertEqual(task['data']['fields']['authorData']['userName'], 'jane') self.assertEqual(task['data']['fields']['ownerData']['userName'], 'jrae') self.assertEqual(len(task['data']['transactions']), 18) self.assertEqual(task['uuid'], 'e8fa3e4a4381d6fea3bcf5c848f599b87e7dc4a6') self.assertEqual(task['origin'], PHABRICATOR_URL) self.assertEqual(task['updated_on'], 1467196707.0) self.assertEqual(task['category'], 'task') self.assertEqual(task['tag'], PHABRICATOR_URL) # Check requests expected = [{ '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'attachments' : {'projects' : True}, 'constraints' : {'modifiedStart' : 1467158400}, 'order' : 'outdated' } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'ids' : [296] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-USER-pr5fcxy4xk5ofqsfqcfc'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-USER-ojtcpympsmwenszuef7p'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-APPS-PhabricatorHeraldApplication'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-PROJ-zi2ndtoy3fh5pnbqzfdo'] } }, { '__conduit__' : ['True'], 'output' : ['json'], 'params' : { '__conduit__' : {'token': 'AAAA'}, 'phids' : ['PHID-PROJ-2qnt6thbrd7qnx5bitzy'] } }] self.assertEqual(len(http_requests), len(expected)) for i in range(len(expected)): rparams = http_requests[i].parsed_body rparams['params'] = json.loads(rparams['params'][0]) self.assertDictEqual(rparams, expected[i])