premium product purchase unit tests.
This commit is contained in:
@@ -18,6 +18,10 @@ from atst.domain.csp.cloud.models import (
|
||||
BillingProfileTenantAccessCSPResult,
|
||||
BillingProfileVerificationCSPPayload,
|
||||
BillingProfileVerificationCSPResult,
|
||||
ProductPurchaseCSPPayload,
|
||||
ProductPurchaseCSPResult,
|
||||
ProductPurchaseVerificationCSPPayload,
|
||||
ProductPurchaseVerificationCSPResult,
|
||||
TaskOrderBillingCreationCSPPayload,
|
||||
TaskOrderBillingCreationCSPResult,
|
||||
TaskOrderBillingVerificationCSPPayload,
|
||||
@@ -335,6 +339,7 @@ def test_create_task_order_billing_creation(mock_azure: AzureCloudProvider):
|
||||
|
||||
result = mock_azure.create_task_order_billing_creation(payload)
|
||||
body: TaskOrderBillingCreationCSPResult = result.get("body")
|
||||
|
||||
assert (
|
||||
body.task_order_billing_verify_url
|
||||
== "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/7c89b735-b22b-55c0-ab5a-c624843e8bf6:de4416ce-acc6-44b1-8122-c87c4e903c91_2019-05-31/operationResults/patchBillingProfile_KQWI-W2SU-BG7-TGB:02715576-4118-466c-bca7-b1cd3169ff46?api-version=2019-10-01-preview"
|
||||
@@ -435,3 +440,90 @@ def test_create_billing_instruction(mock_azure: AzureCloudProvider):
|
||||
result = mock_azure.create_billing_instruction(payload)
|
||||
body: BillingInstructionCSPResult = result.get("body")
|
||||
assert body.reported_clin_name == "TO1:CLIN001"
|
||||
|
||||
|
||||
def test_create_product_purchase(mock_azure: AzureCloudProvider):
|
||||
mock_azure.sdk.adal.AuthenticationContext.return_value.context.acquire_token_with_client_credentials.return_value = {
|
||||
"accessToken": "TOKEN"
|
||||
}
|
||||
|
||||
mock_result = Mock()
|
||||
mock_result.status_code = 202
|
||||
mock_result.headers = {
|
||||
"Location": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/7c89b735-b22b-55c0-ab5a-c624843e8bf6:de4416ce-acc6-44b1-8122-c87c4e903c91_2019-05-31/operationResults/patchBillingProfile_KQWI-W2SU-BG7-TGB:02715576-4118-466c-bca7-b1cd3169ff46?api-version=2019-10-01-preview",
|
||||
"Retry-After": "10",
|
||||
}
|
||||
|
||||
mock_azure.sdk.requests.post.return_value = mock_result
|
||||
|
||||
payload = ProductPurchaseCSPPayload(
|
||||
**dict(
|
||||
creds=creds,
|
||||
type="AADPremium",
|
||||
sku="AADP1",
|
||||
productProperties={
|
||||
"beneficiaryTenantId": str(uuid4()),
|
||||
},
|
||||
quantity=4,
|
||||
billing_account_name="7c89b735-b22b-55c0-ab5a-c624843e8bf6:de4416ce-acc6-44b1-8122-c87c4e903c91_2019-05-31",
|
||||
billing_profile_name="KQWI-W2SU-BG7-TGB",
|
||||
)
|
||||
)
|
||||
|
||||
result = mock_azure.create_product_purchase(payload)
|
||||
body: ProductPurchaseCSPResult = result.get("body")
|
||||
assert (
|
||||
body.product_purchase_verify_url == "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/7c89b735-b22b-55c0-ab5a-c624843e8bf6:de4416ce-acc6-44b1-8122-c87c4e903c91_2019-05-31/operationResults/patchBillingProfile_KQWI-W2SU-BG7-TGB:02715576-4118-466c-bca7-b1cd3169ff46?api-version=2019-10-01-preview"
|
||||
)
|
||||
|
||||
def test_create_product_purchase_verification(mock_azure):
|
||||
mock_azure.sdk.adal.AuthenticationContext.return_value.context.acquire_token_with_client_credentials.return_value = {
|
||||
"accessToken": "TOKEN"
|
||||
}
|
||||
|
||||
mock_result = Mock()
|
||||
mock_result.status_code = 200
|
||||
mock_result.json.return_value = {
|
||||
"status": "string",
|
||||
"product": {
|
||||
"id": "string",
|
||||
"name": "string",
|
||||
"type": "string",
|
||||
"properties": {
|
||||
"displayName": "string",
|
||||
"purchaseDate": "2020-01-30T18:57:05.981Z",
|
||||
"productTypeId": "string",
|
||||
"productType": "string",
|
||||
"status": "Active",
|
||||
"endDate": "2020-01-30T18:57:05.981Z",
|
||||
"billingFrequency": "OneTime",
|
||||
"lastCharge": {
|
||||
"currency": "string",
|
||||
"value": 0
|
||||
},
|
||||
"lastChargeDate": "2020-01-30T18:57:05.981Z",
|
||||
"quantity": 0,
|
||||
"skuId": "string",
|
||||
"skuDescription": "string",
|
||||
"availabilityId": "string",
|
||||
"parentProductId": "string",
|
||||
"invoiceSectionId": "string",
|
||||
"invoiceSectionDisplayName": "string",
|
||||
"billingProfileId": "string",
|
||||
"billingProfileDisplayName": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mock_azure.sdk.requests.get.return_value = mock_result
|
||||
|
||||
payload = ProductPurchaseVerificationCSPPayload(
|
||||
**dict(
|
||||
creds=creds,
|
||||
product_purchase_verify_url="https://management.azure.com/providers/Microsoft.Billing/billingAccounts/7c89b735-b22b-55c0-ab5a-c624843e8bf6:de4416ce-acc6-44b1-8122-c87c4e903c91_2019-05-31/operationResults/createBillingProfile_478d5706-71f9-4a8b-8d4e-2cbaca27a668?api-version=2019-10-01-preview",
|
||||
)
|
||||
)
|
||||
|
||||
result = mock_azure.create_product_purchase_verification(payload)
|
||||
body: ProductPurchaseVerificationCSPResult = result.get("body")
|
||||
assert body.premium_purchase_date == "2020-01-30T18:57:05.981Z"
|
||||
|
Reference in New Issue
Block a user