utils

Utilities functions for tests.

integrade.tests.utils.create_cloud_account(auth, n, cloudtrails_to_delete=None, name=<object object>)

Create a cloud account based on configured AWS customer info.

integrade.tests.utils.create_user_account(user=None)

Create a new user account.

Parameters:user – A dictionary with the arguments to be passed to the Django’s create_user helper function.
integrade.tests.utils.days_in_month(year, month)

Return the number of days on a given month.

Returns:An integer with the number of days a given month has.
integrade.tests.utils.delete_cloudtrails(cloudtrails_to_delete=None)

Delete cloudtrails.

The cloudtrails_to_delete param must be a list of tuples of (aws_profile, cloudtrail_name).

integrade.tests.utils.drop_account_data()

Drop all account data from the cloudigrade’s database.

integrade.tests.utils.drop_image_data()

Drop all image data from the cloudigrade’s database.

integrade.tests.utils.get_auth(user=None)

Get authentication for given user to use with requests.

For example::
usr = create_user_account({
‘email’: ‘’, ‘password’: gen_password(), ‘username’: uuid4(),

}) auth = get_auth(username, pwd) client = api.Client(authenticate=False) client.get(urls.AUTH_ME, auth=auth)

If no user is provided, a new user is created. This is useful when you need to make authenticated requests as a regular user, but never need to use the user information for anything else.

Example:

from integrade.tests import urls
client = api.client(authenticate=False)
auth1 = get_user_and_auth()
client.get(urls.CLOUD_ACCOUNT, auth=auth1)
Returns:instance of api.TokenAuth
integrade.tests.utils.get_time_range(offset=0, formatted=True)

Create start/end time for parameters to account report API.

integrade.tests.utils.needed_aws_profiles_present(num_profiles=1)

Return True if the number of profiles indicated are present.

See the README for how aws profiles for customers are defined.

integrade.tests.utils.utc_dt(*args, **kwargs)

Wrap datetime construction to force result to UTC.

Returns:datetime.datetime instance with its timezone set to UTC.
integrade.tests.utils.utc_now(*args, **kwargs)

Return the datetime.now forcing result to UTC.

Returns:datetime.datetime instance with its timezone set to UTC.