def test_get_organisations(accounting_api: AccountingApi, xero_tenant_id): """ Test AccountingApi.get_organisations() """ # Given correct api client and xero tenant id # When fetching organisations response = accounting_api.get_organisations(xero_tenant_id=xero_tenant_id) # Then expect correct response with organisations tenant has access to assert isinstance(response, models.Organisations) organisations = response.organisations assert isinstance(organisations, list) assert len(organisations) == 1 org = organisations[0] assert isinstance(org, models.Organisation) assert org.organisation_id assert org.is_demo_company
def tenants(): identity_api = IdentityApi(api_client) accounting_api = AccountingApi(api_client) available_tenants = [] for connection in identity_api.get_connections(): tenant = serialize(connection) if connection.tenant_type == "ORGANISATION": organisations = accounting_api.get_organisations( xero_tenant_id=connection.tenant_id) tenant["organisations"] = serialize(organisations) available_tenants.append(tenant) return render_template( "code.html", title="Xero Tenants", code=json.dumps(available_tenants, sort_keys=True, indent=4), )