Skip to content

Commit

Permalink
[DE-1091] Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maciej-nedza committed Dec 13, 2024
1 parent 3797071 commit 082cd61
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
9 changes: 3 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

BASIC_AUTH_USERNAME = os.getenv("BASIC_AUTH_USERNAME")
BASIC_AUTH_PASSWORD = os.getenv("BASIC_AUTH_PASSWORD")
DOMAIN = os.getenv("DOMAIN")
SUBDOMAIN = os.getenv("SUBDOMAIN")


Expand All @@ -41,16 +40,15 @@ def clean_custom_fields(client: AdvancedBillingClient):
@pytest.fixture(scope="session", autouse=True)
def client() -> AdvancedBillingClient:
client = AdvancedBillingClient(
subdomain=SUBDOMAIN,
domain=DOMAIN,
site=SUBDOMAIN,
basic_auth_credentials=BasicAuthCredentials(
username=BASIC_AUTH_USERNAME,
password=BASIC_AUTH_PASSWORD
)
)

clean_custom_fields(client)
client.sites.clear_site()
#client.sites.clear_site()
sleep(10) # Wait for site to be cleared as it takes some time

yield client
Expand All @@ -59,8 +57,7 @@ def client() -> AdvancedBillingClient:
@pytest.fixture(scope="session")
def unauthorized_client() -> AdvancedBillingClient:
return AdvancedBillingClient(
subdomain=SUBDOMAIN,
domain=DOMAIN,
site=SUBDOMAIN,
basic_auth_credentials=BasicAuthCredentials(
username="thisiswrongapitokenthisiswrongapitokenV8",
password=BASIC_AUTH_PASSWORD
Expand Down
3 changes: 2 additions & 1 deletion tests/data/init_cases.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from random import Random
from uuid import uuid4

from advancedbilling.models.component import Component
Expand Down Expand Up @@ -198,7 +199,7 @@ def get_allocation_request(
def get_coupon_data() -> dict:
return {
"name": "15% off",
"code": "15OFF",
"code": "15OFF" + str(Random().randint(1000, 10000)),
"percentage": "15",
"description": "15% off for life",
"allow_negative_balance": False,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from advancedbilling.models.coupon import Coupon
from advancedbilling.models.create_customer_request import CreateCustomerRequest
from advancedbilling.models.create_invoice_request import CreateInvoiceRequest
from advancedbilling.models.create_or_update_coupon import CreateOrUpdateCoupon
from advancedbilling.models.coupon_request import CouponRequest
from advancedbilling.models.create_or_update_product_request import (
CreateOrUpdateProductRequest,
)
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_create_invoice_given_subscription_then_return_correct_invoice(
).payment_profile

coupon: Coupon = coupons_controller.create_coupon(
product_family.id, CreateOrUpdateCoupon(InitCases.get_coupon_data())
product_family.id, CouponRequest(InitCases.get_coupon_data())
).coupon

subscription: Subscription = subscriptions_controller.create_subscription(
Expand Down

0 comments on commit 082cd61

Please sign in to comment.