Skip to main content

CMS FAQ Management — Automated UAT Tests

Automated validation suite for the CMS FAQ Management extension. Tests the FAQ API, BC OData endpoints, cross-system data consistency, and posted document preservation.

Overview

This test suite automates 17 of the 36 test cases from the UAT Test Plan (Epic 193). Tests are organized into three tiers based on their system dependencies:

TierSystemsCredential RequirementsTest Count
Tier 1FAQ API onlyFAQ_API_* env vars7
Tier 2BC OData onlyBC_* env vars~15
Tier 3Both FAQ + BCAll env vars5

A snapshot marker identifies tests that require pre-captured data (before/after comparisons).

Prerequisites

  • Python 3.10+
  • Access to the Bestway FAQ API (for tier 1 and tier 3 tests)
  • Azure AD app registration with BC API permissions (for tier 2 and tier 3 tests)
  • bc-csm-api extension v1.1.0.0 published to the BC sandbox (provides the OData endpoints)

Setup

cd "CMS FAQ Management/test"
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Copy .env.example to .env and fill in credentials:

cp .env.example .env
VariableDescription
FAQ_API_BASE_URLFAQ API root URL
FAQ_API_USERNAMEFAQ login username
FAQ_API_PASSWORDFAQ login password
BC_TENANT_IDAzure AD tenant ID (GUID)
BC_CLIENT_IDAzure AD app registration client ID
BC_CLIENT_SECRETAzure AD app registration client secret
BC_ENVIRONMENTBC environment name (default: sandbox)
BC_COMPANY_IDBC company ID (GUID)

Running Tests

# All tests (skips automatically if credentials are missing)
pytest

# By tier
pytest -m tier1 # FAQ API only
pytest -m tier2 # BC OData only
pytest -m tier3 # Cross-system

# Snapshot tests only
pytest -m snapshot

# Exclude snapshot tests
pytest -m "not snapshot"

# Specific test file
pytest tests/test_tier1_faq_api.py

# Specific test
pytest tests/test_tier2_bc_data.py::TestFieldPopulation::test_table_has_records

Snapshot Workflow

Snapshot tests compare BC data before and after a specific operation. The workflow is:

  1. Capture the "before" state using run_snapshot.py.
  2. Trigger the operation manually in BC (full rebuild, incremental sync, etc.).
  3. Capture the "after" state.
  4. Run the snapshot tests — they load both snapshots and compare.

TC-1.2A: Full Rebuild Inactivation

Verifies that a full rebuild marks pre-existing records inactive (rather than deleting them).

python run_snapshot.py capture pre
# → In BC: trigger a full rebuild via the FAQ Management page
python run_snapshot.py capture post
pytest -m snapshot -k "rebuild_inactivation"

TC-1.2B / TC-5.3A: Rebuild Idempotency

Verifies that running a full rebuild twice produces identical results.

python run_snapshot.py capture post_rebuild_1
# → In BC: trigger a second full rebuild
python run_snapshot.py capture post_rebuild_2
pytest -m snapshot -k "idempotency"

TC-9.1 / TC-9.2: Posted Document Preservation

Verifies that posted service invoices and shipments are not modified by a sync.

python run_snapshot.py capture pre_sync
# → In BC: trigger a sync (full or incremental)
python run_snapshot.py capture post_sync
pytest -m snapshot -k "preservation"

Managing Snapshots

# List all captured snapshots
python run_snapshot.py list

Snapshots are saved as JSON files in the snapshots/ directory (gitignored). Each snapshot contains one JSON file per table plus a metadata.json with timestamps and row counts.

Test Case Mapping

TCDescriptionFileTier
TC-1.1API Authenticationtest_tier1_faq_api.py1
TC-1.2AFull Rebuild Inactivationtest_tier2_snapshots.py2/snapshot
TC-1.2BFull Rebuild Idempotencytest_tier2_snapshots.py2/snapshot
TC-3.1Sync Field Presencetest_tier2_bc_data.py2
TC-3.2Field Populationtest_tier2_bc_data.py2
TC-3.3Mapping Integritytest_tier3_cross_system.py3
TC-4.1Code Correlationtest_tier3_cross_system.py3
TC-4.3Code Uniquenesstest_tier1_faq_api.py + test_tier2_bc_data.py1 + 2
TC-5.3ARebuild Idempotencytest_tier2_snapshots.py2/snapshot
TC-8.1Hierarchy Mappingtest_tier1_faq_api.py + test_tier3_cross_system.py1 + 3
TC-8.2Relationship Tablestest_tier1_faq_api.py + test_tier2_bc_data.py1 + 2
TC-8.3Service Item Grouptest_tier2_bc_data.py2
TC-9.1PSI Preservationtest_tier2_snapshots.py2/snapshot
TC-9.2SO Preservationtest_tier2_snapshots.py2/snapshot

Project Structure

CMS FAQ Management/test/
├── README.md # This file
├── requirements.txt # Python dependencies
├── .env.example # Credential template
├── .gitignore # .env, .venv/, snapshots/
├── pytest.ini # Markers, test paths, verbosity
├── conftest.py # Fixtures, skip logic, client setup
├── run_snapshot.py # CLI for capturing/listing snapshots
├── tests/
│ ├── __init__.py
│ ├── test_tier1_faq_api.py # FAQ API tests (TC-1.1, 4.3, 8.1, 8.2)
│ ├── test_tier2_bc_data.py # BC data tests (TC-3.1, 3.2, 4.3, 8.3)
│ ├── test_tier2_snapshots.py # Snapshot tests (TC-1.2A/B, 5.3A, 9.1, 9.2)
│ └── test_tier3_cross_system.py # Cross-system tests (TC-3.3, 4.1, 8.1)
└── snapshots/ # Captured snapshots (gitignored)
└── .gitkeep

Shared Dependencies

The test suite imports shared modules from tools/ at the repository root:

ModulePurpose
tools/bc_odata_client.pyOAuth2 client for BC OData v4 endpoints
tools/faq_api_client.pyFAQ API client
tools/snapshot_lib.pySnapshot capture, load, and diff

These are imported via sys.path.insert in conftest.py — no package installation required.

Known Limitations

  1. FAQ Management extension only adds Status to Fault Area. The CMS FAQ Management extension (Sataware Technologies) adds a single Status field to the Fault Area table only — not to Symptom Codes, Fault Codes, or Resolution Codes. TC-3.1 validates this field on Fault Areas. The CSM API Toolkit v1.5.0.0 exposes it via OData.

  2. Cross-system mapping tests are approximate. TC-3.3 and TC-4.1 verify that both systems have data, but the exact FAQ→BC field mapping (which FAQ field maps to which BC column) needs to be confirmed after the extension is deployed. Tests will be tightened once the mapping is known.

  3. Snapshot tests require manual BC operations. The "trigger sync" step between snapshot captures must be done manually in BC. These tests cannot run fully unattended.