def test_list_users_without_status(mock_data_client): output = StringIO() framework_slug = 'g-cloud-7' mock_data_client.find_users_iter.return_value = [ user(), ] mock_data_client.get_interested_suppliers.return_value = {'interestedSuppliers': [1234]} list_users(mock_data_client, output, framework_slug, False) assert output.getvalue() == "[email protected],Jane Example,1234,Examples Ltd.\r\n"
def test_list_users_with_status(mock_data_client): output = StringIO() framework_slug = 'g-cloud-7' mock_data_client.find_users_iter.return_value = [ user(), ] mock_data_client.get_supplier_declaration.return_value = {'declaration': {'status': 'complete'}} mock_data_client.get_interested_suppliers.return_value = {'interestedSuppliers': [1234]} list_users(mock_data_client, output, framework_slug, True) assert output.getvalue() == "complete,[email protected],Jane Example,1234,Examples Ltd.\r\n"
""" Usage: scripts/generate-user-email-list.py <data_api_url> <data_api_token> [--framework=<slug>] [--status] """ import sys sys.path.insert(0, '.') from docopt import docopt from dmutils.apiclient import DataAPIClient from dmscripts.generate_user_email_list import list_users if __name__ == '__main__': arguments = docopt(__doc__) client = DataAPIClient(arguments['<data_api_url>'], arguments['<data_api_token>']) output = sys.stdout framework_slug = arguments.get('--framework') include_status = bool(arguments.get('--status')) list_users(client, output, framework_slug, include_status)