User Acceptance Testing¶
UAT (User Acceptance Testing) on this platform reuses the regression harness — there is no separate UAT-only tool. The difference is in scenario shape and audience: regression tests pin a single invariant in the smallest possible setup, UAT scenarios walk a business-readable journey end-to-end and assert at user-visible boundaries.
The same six fixtures (db, crm, dia, cdr, ref, vp), the same MSISDN prefix scoping, the same teardown rules apply. A UAT scenario is just a pytest test that happens to read like an acceptance criterion.
When to write a UAT scenario vs. a regression test¶
| Question | UAT | Regression |
|---|---|---|
| Audience | Product / operator / customer success | Developer / platform team |
| Granularity | "A new prepaid customer can buy a voucher, redeem it, and place a call." | "RedeemVoucher mutates vouchers.status_id from 1 to 2." |
| Number of platform surfaces touched | 2-4 (CRM RPC → DB → DIAMETER → bill) | 1 |
| Assertion shape | "The PDF shows the customer's name and the right total" | "bills.tax_amount == round(subtotal*0.19, 2)" |
| Failure mode | "Customer journey broken" | "Single contract violation" |
In practice every UAT scenario decomposes into a sequence of the same primitives the regression tests use. The harness is designed so the same test file can carry either shape; the only difference is the docstring, the assertion granularity, and (optionally) the marker.
Recommended layout¶
Place UAT scenarios alongside the flow they primarily exercise, with a uat_ prefix on the filename:
usr/share/tests/backend/tests/
├── flow4_subscriber/
│ ├── test_f4_01_create_postpaid.py # regression
│ ├── test_f4_05_suspend.py # regression
│ ├── uat_new_prepaid_subscriber_journey.py # UAT
│ └── uat_postpaid_subscriber_lifecycle.py # UAT
Mark each UAT test so it can be selected in isolation:
import pytest
@pytest.mark.uat
@pytest.mark.flow4
def test_new_prepaid_subscriber_journey(db, crm, dia, cdr, vp):
with vp.result("UAT — new prepaid subscriber: create → top-up → call → debit"):
# … scenario body …
Register the marker once in pytest.ini:
markers =
flow1: CDR rating tests (Stage 3)
flow2: DIAMETER tests (Stage 3)
flow3: Invoice tests (Stage 4)
flow4: Subscriber lifecycle tests (Stage 4)
flow5: Mediation tests (Stage 5)
flow6: Roaming tests (Stage 5)
flow7: Product Catalogue tests
flow8: End-to-end convergent-billing use-cases
uat: User-acceptance scenarios (cross-flow, business-readable)
missing: test depends on platform functionality not yet shipped — skip with reason
Run them via the marker:
Or wire the marker into run_tests.sh (one-line change to the --flow case statement) if your team treats UAT as a first-class category.
Authoring a scenario¶
The five-step shape from the regression tests carries over verbatim:
vp.setup(...)— describe the world state the customer is starting in.vp.send(...)— describe the customer-visible action (RPC, voucher redemption, call).vp.recv(...)— describe the customer-visible response.vp.expect(...)/vp.expect_eq(...)— one assertion per business invariant.finally: cleanup— DELETE the rows the scenario seeded.
The verbose tags are intentionally English-shaped. A non-engineer reading the log can reconstruct what the scenario did without opening the source.
Worked example: "new prepaid subscriber buys a voucher and places a call"¶
import pytest
from lib import types_pb2
PLAN_ID = 3 # seeded "Free Plan"
VOUCHER_VALUE_EUR = 25.0
CALL_DURATION = 60
@pytest.mark.uat
@pytest.mark.flow4
def test_uat_new_prepaid_buys_voucher_places_call(db, crm, dia, cdr, vp):
with vp.result("UAT — new prepaid sub buys voucher, places a 60s call"):
msisdn = cdr.reserved_msisdn(91)
sub_id = balance_id = resource_id = voucher_id = None
code = "TEST-UAT-91"
try:
vp.setup("Customer Service creates a new prepaid subscriber via the CRM")
req = types_pb2.Subscriber(
prepaid=1, postpaid=0, plan_id=PLAN_ID, status=1, billcycle=1,
currency_id=1,
msisdn=types_pb2.Resource(value=msisdn, type=1, status=2),
balance=types_pb2.Balance(balance=0.0, reserved=0.0),
address=types_pb2.Address(
ssn="UAT-91", name="UAT Subscriber 91",
email="uat91@example.com", city="Bucharest", county_id=40),
)
resp = crm.stub.CreateSubscriber(req, metadata=crm.meta())
vp.expect_eq(resp.success, True, "Subscriber created")
sub_id = resp.subscriber_id
vp.setup("Operator pre-loads a voucher into the inventory")
db.execute(
"INSERT INTO vouchers (operator_id, value, code, status_id) "
"VALUES (3, %s, %s, 1)", (VOUCHER_VALUE_EUR, code))
voucher_id = db.query_scalar("SELECT LAST_INSERT_ID()")
vp.send(f"Customer redeems voucher {code} via the self-service portal")
r = crm.stub.RedeemVoucher(
types_pb2.RedeemVoucherRequest(subscriber_id=sub_id, code=code),
metadata=crm.meta())
vp.recv(f"Balance after redemption: {r.new_balance:.2f} EUR")
vp.expect(abs(r.new_balance - VOUCHER_VALUE_EUR) < 1e-4,
"Balance equals the voucher's face value")
vp.send(f"Customer places a {CALL_DURATION}s voice call")
ccr = dia.CCR(request_type=dia.CCR_INITIAL, msisdn=msisdn,
service_id=1, requested_units=CALL_DURATION)
cca = dia.send_raw(ccr)
vp.recv(f"Network grants {cca.granted_units}s (Result-Code={cca.result_code})")
vp.expect_eq(cca.result_code, dia.RC_SUCCESS, "Call was authorised")
vp.expect_eq(cca.granted_units, CALL_DURATION, "All requested units granted")
finally:
vp.teardown("Cleaning up UAT artefacts")
# … standard cleanup pattern …
What the operator sees on the terminal:
[TEST] UAT — new prepaid sub buys voucher, places a 60s call
[SETUP] Customer Service creates a new prepaid subscriber via the CRM
[SETUP] Operator pre-loads a voucher into the inventory
[SEND] Customer redeems voucher TEST-UAT-91 via the self-service portal
[RECV] Balance after redemption: 25.00 EUR
[ASSERT] Balance equals the voucher's face value … PASS
[SEND] Customer places a 60s voice call
[RECV] Network grants 60s (Result-Code=2001)
[ASSERT] Call was authorised … PASS
[ASSERT] All requested units granted … PASS
[RESULT] PASS (43ms)
That output is the acceptance evidence: a non-engineer can sign off on it directly.
Ready-made UAT scenarios already in the suite¶
These existing tests are essentially UAT in shape; they exercise multi-step customer journeys and can be cited verbatim during acceptance review:
| Test | Journey |
|---|---|
| F2-09 | A subscriber tops up a balance via voucher during an active DIAMETER session. |
| F4-01 .. F4-02 | Customer Service creates a postpaid / prepaid subscriber end-to-end. |
| F4-05 → F4-08 | Operator suspends a subscriber, network rejects subsequent CCRs with 4010. |
| F4-09 | Customer redeems a voucher and balance is credited. |
| F3-01 | Monthly invoice for a postpaid customer with usage across multiple services + VAT. |
| F3-04 | Reissuing an invoice produces a new PDF and increments the reissue counter. |
| F3-06 | A foreign-currency customer's invoice prints amounts in their currency. |
A UAT pass for a release can be assembled simply by running the existing flows under the --verbose flag and capturing the output:
The log is human-readable and can be attached to a release ticket.
Recommended cadence¶
| Trigger | What to run |
|---|---|
| New customer-visible behaviour landed | Add the corresponding UAT scenario before merge. |
| Pre-release acceptance | Full --stage 4 (Flows 3 + 4 carry every customer journey). |
| Customer-reported issue | Author a UAT scenario reproducing the issue, file it as a non-conformity if it reproduces, ship it as a regression once the platform fix lands. |
When the assertion needs UI / PDF inspection¶
For the bill-formatter PDFs, F3-06 already demonstrates the pattern (pdftotext if available, raw-byte fallback otherwise). Re-use tests/flow3_invoice/test_f3_06_multi_currency.py::_pdf_text for any UAT that needs to assert on PDF content.
For the CRM web UI (PHP, var/www/), the only UI-level check shipped today is the sign-in → dashboard test in the deployment acceptance pack (usr/share/tests/e2e/tests/test_e2e_crm.py); there is no browser-driven UAT layer. Either drive the underlying gRPC RPCs (which is what the UI does anyway and what the suite already exercises) or add a browser-driver layer in a new flow directory.