def test_add_framework_info_fails_on_non_404_error(mock_data_client): mock_data_client.get_supplier_framework_info.side_effect = HTTPError(Mock(status_code=400)) framework_info_adder = export_dos_suppliers.add_framework_info(mock_data_client, 'framework-slug') with pytest.raises(HTTPError): framework_info_adder({'supplier_id': 1})
def test_add_framework_info_fails_if_incomplete_declaration_is_not_failed(mock_data_client): mock_data_client.get_supplier_framework_info.return_value = { 'frameworkInterest': {'declaration': {'status': 'incomplete'}, 'onFramework': None} } framework_info_adder = export_dos_suppliers.add_framework_info(mock_data_client, 'framework-slug') with pytest.raises(AssertionError): framework_info_adder({'supplier_id': 1})
def find_all_labs(client): pool = ThreadPool(20) records = find_suppliers(client, FRAMEWORK_SLUG) records = pool.imap(add_framework_info(client, FRAMEWORK_SLUG), records) records = filter(lambda record: record['onFramework'], records) records = pool.imap(add_draft_services(client, FRAMEWORK_SLUG), records) services = itertools.chain.from_iterable(record['services'] for record in records) services = filter( lambda record: record['lot'] == 'user-research-studios' and record['status'] == 'submitted', services) return services
def test_add_framework_info(mock_data_client): mock_data_client.get_supplier_framework_info.side_effect = [ {'frameworkInterest': {'declaration': {'status': 'complete'}, 'onFramework': True}}, {'frameworkInterest': {'declaration': {'status': 'complete'}, 'onFramework': False}}, ] framework_info_adder = export_dos_suppliers.add_framework_info(mock_data_client, 'framework-slug') records = [ framework_info_adder({'supplier_id': 1}), framework_info_adder({'supplier_id': 2}), ] mock_data_client.get_supplier_framework_info.assert_has_calls([ call(1, 'framework-slug'), call(2, 'framework-slug') ]) assert records == [ {'supplier_id': 1, 'declaration': {'status': 'complete'}, 'onFramework': True}, {'supplier_id': 2, 'declaration': {'status': 'complete'}, 'onFramework': False}, ]