parent
819e13481e
commit
6443582c0e
5 changed files with 87 additions and 12 deletions
|
|
@ -3,6 +3,7 @@ import base64
|
|||
import pytest
|
||||
|
||||
from servala.core.models import (
|
||||
BillingEntity,
|
||||
Organization,
|
||||
OrganizationMembership,
|
||||
OrganizationOrigin,
|
||||
|
|
@ -21,6 +22,11 @@ def origin():
|
|||
return OrganizationOrigin.objects.create(name="TESTORIGIN")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def billing_entity():
|
||||
return BillingEntity.objects.create(name="Test Entity")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def organization(origin):
|
||||
return Organization.objects.create(name="Test Org", origin=origin)
|
||||
|
|
|
|||
|
|
@ -99,6 +99,36 @@ def test_successful_onboarding_new_organization(
|
|||
assert "redis/offering/" in welcome_email.body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_new_organization_inherits_origin(
|
||||
osb_client,
|
||||
test_service,
|
||||
test_service_offering,
|
||||
valid_osb_payload,
|
||||
exoscale_origin,
|
||||
instance_id,
|
||||
billing_entity,
|
||||
):
|
||||
valid_osb_payload["service_id"] = test_service.osb_service_id
|
||||
valid_osb_payload["plan_id"] = test_service_offering.osb_plan_id
|
||||
exoscale_origin.billing_entity = billing_entity
|
||||
exoscale_origin.save()
|
||||
|
||||
response = osb_client.put(
|
||||
f"/api/osb/v2/service_instances/{instance_id}",
|
||||
data=json.dumps(valid_osb_payload),
|
||||
content_type="application/json",
|
||||
)
|
||||
|
||||
assert response.status_code == 201
|
||||
response_data = json.loads(response.content)
|
||||
assert response_data["message"] == "Successfully enabled service"
|
||||
|
||||
org = Organization.objects.get(osb_guid="test-org-guid-123")
|
||||
assert org.name == "Test Organization Display"
|
||||
assert org.billing_entity == exoscale_origin.billing_entity
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_duplicate_organization_returns_existing(
|
||||
osb_client,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue