# bittersoftware/stb-tester-automation architecture

> Architecture diagram of the GitHub repository bittersoftware/stb-tester-automation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bittersoftware/stb-tester-automation
- Repository: https://github.com/bittersoftware/stb-tester-automation

## Overview

##### Project Type and Purpose
- It uses the Page Object Model (POM) to encapsulate UI/menu screens, drives the device via a mock “device_access” layer, and reports/manages tests via a mock “test_management” layer.
- Test cases (TC-1…TC-12) exercise decoder features (zapping, living apps, KPI, network capture).

##### High-Level Components
a. Test Runner / Test Cases
- test_cases/*.py
- Orchestrates scenarios using page objects, utils, device and test-management services.
b. Page Object Model (POM)
- common/la/* and common/pages/*
- Defines static elements (images), visibility checks, and actions for each screen.
c. Utilities
- common/utils/*.py and utils/imports_utils.py
- Shared helpers: timestamp, navigation logic, OCR corrections, plotting.
d. Device Access Layer
- device_access/device_access.py
- Abstracts SSH/Telnet/REST commands to the physical decoder (mocked in this repo).
e. Test Management Layer
- test_management/test_management.py
- Abstracts test-plan retrieval (JIRA, CSV) and result reporting (mocked).
f. Configuration
- config.conf
- Contains environment settings (e.g. device credentials, timeouts).
g. External Dependencies
- stbt library for frame capture & object matching
- Network-capture analyzer (used by TC-8 & TC-10)

##### Relationships & Data Flow
- The Test Runner loads config.conf and test_management to pick up test plans.
- For each test case:
- It uses imports_utils to dynamically load the TC module.
- The TC calls page_object.perform_some_action() to navigate on screen.
- PageObject classes use stbt to capture frames and match reference images.
- When actions invoke remote operations (e.g. changing channel), PageObject uses device_access APIs.
- device_access sends commands to the decoder and returns status.
- Test logic may call common/utils.plot or the external network analyzer for charts.
- Test results and metrics are handed back to test_management for final reporting.

##### Architectural Patterns & Design Principles
- Page Object Model: keeps UI-screen locators and actions in one place.
- Layered Architecture: separation of concerns between Test Orchestration, POM, Device I/O, Test Management, and Utilities.
- Dependency Injection via imports_utils for modularity of test cases.
- Mocking of external services (device, test plan) for demo purposes.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Core Framework"
        direction TB
        TestRunner["Test Runner"]:::core
        TestCases["Test Cases\n(test_cases/*.py)"]:::core
        ImportsUtil["Imports Utility\n(utils/imports_utils.py)"]:::core
        subgraph "Page Object Model"
            direction TB
            LA["LA Screens\n(common/la/)"]:::core
            Pages["UI Pages\n(common/pages/)"]:::core
        end
        Utils["Utilities\n(common/utils/*.py)"]:::core
    end

    subgraph "Mocks/Adapters"
        direction TB
        DeviceAccess["Device Access Layer\n(device_access/device_access.py)"]:::mock
        TestManagement["Test Management Layer\n(test_management/test_management.py)"]:::mock
    end

    subgraph "Configuration"
        Config["config.conf"]:::core
    end

    subgraph "External Services"
        direction TB
        STBT["stbt library"]:::external
        NetAnalyzer["Network Analyzer"]:::external
        Decoder["Physical Decoder"]:::external
    end

    Config --> TestRunner
    TestRunner --> TestCases
    TestRunner --> TestManagement
    TestRunner --> ImportsUtil
    TestCases --> ImportsUtil
    TestCases --> LA
    TestCases --> Pages
    LA --> STBT
    Pages --> STBT
    TestCases --> Utils
    Utils --> NetAnalyzer
    Pages --> DeviceAccess
    DeviceAccess --> Decoder
    TestCases --> TestManagement

    click TestCases "https://github.com/bittersoftware/stb-tester-automation/tree/main/test_cases/"
    click LA "https://github.com/bittersoftware/stb-tester-automation/tree/main/common/la/"
    click Pages "https://github.com/bittersoftware/stb-tester-automation/tree/main/common/pages/"
    click Utils "https://github.com/bittersoftware/stb-tester-automation/tree/main/common/utils/"
    click ImportsUtil "https://github.com/bittersoftware/stb-tester-automation/blob/main/utils/imports_utils.py"
    click DeviceAccess "https://github.com/bittersoftware/stb-tester-automation/blob/main/device_access/device_access.py"
    click TestManagement "https://github.com/bittersoftware/stb-tester-automation/blob/main/test_management/test_management.py"
    click Config "https://github.com/bittersoftware/stb-tester-automation/blob/main/config.conf"

    classDef core fill:#ADD8E6,stroke:#000;
    classDef mock fill:#90EE90,stroke-dasharray:5 5;
    classDef external fill:#FFA500,stroke:#000;
```
