Skip to main content

Regression Framework

This microservice creates a framework for running regression tests

Sample Test Case

The header specifies the runner and the comparator.

The runner is the name of the function that will be used to create the actual results.

The comparator is the name of the function that will be used to compare the actual results to the expected results.

Each test file can contain multiple test cases.

By convention, each test file should correspond to an issue in GitHub.

Each test file should test a single aspect or function of the system, using as many variations in input as are necessary to ensure the design is functional.

engine:
  runner: "mutato"
  comparator: "mutato"
  loglevel: ERROR
  ontologies:
    - unitest

## ---------------------------------------------------------- ##
## Purpose:     Testing Swap for "Doctoral Degree"
## Reference:   https://github.com/craigtrim/owl-parse/issues/6
## ---------------------------------------------------------- ##

cases:
  - id: 06-01
    ## ---------------------------------------------------------- ##
    ##  Purpose:    Span 'doctoral degree'
    ## ---------------------------------------------------------- ##
    input: regression/inputs/tokens-0001.json
    output:
      - normal: "doctoral_degree"

Driver Tutorial

Each project that implements this service will need to create a driver.

The driver is responsible for calling regression-framework\regression_framework\bp\regression_api.py with the correct parameters, as well as implementing the runner(s) and comparator(s).

Driver

A simple but functional driver looks like this:

import os
from typing import Callable
from baseblock import FileIO
from baseblock import BaseObject
from regression_framework.bp import RegressionAPI

class RegressionDriver(BaseObject):

    def __init__(self):
        BaseObject.__init__(self, __name__)

    def find_runner(self,
                    d_test_case: dict) -> Callable:

        runner_name = d_test_case['engine']['runner']

        if runner_name == "mutato":
            return self.runner

        raise NotImplementedError(runner_name)

    def find_comparator(self,
                        d_test_case: dict) -> Callable:

        runner_name = d_test_case['engine']['runner']

        if runner_name == "mutato":
            return self.comparator

        raise NotImplementedError(runner_name)

    def run(self):

        api = RegressionAPI(find_runner=self.find_runner,
                            find_comparator=self.find_comparator)

        api.process(FileIO.join_cwd("regression/cases"))

Note that the driver must implement a finder method for the runner and comparator.

The regression framework supports the notion of multiple runners and multiple comparators and each corresponds to this aspect of the test file:

engine:
  runner: "mutato"
  comparator: "mutato"

Runner

The runner (in this case) looks like this:

def runner(self,
            ontologies: list,
            input_text: str) -> str:

    from owl_parse import owl_parse

    def get_content() -> list:
        if FileIO.exists(input_text):
            return FileIO.read_json(input_text)
        raise NotImplementedError(input_text)

    absolute_path = FileIO.join_cwd('resources/testing')

    return owl_parse(tokens=get_content(),
                        ontology_name=ontologies[0],
                        absolute_path=absolute_path)

It is a simple invocation of a known method, with the correct parameters, and the results are returned.

Comparator

The comparator looks like this:

def comparator(self,
                actual_results: object,
                expected_results: object) -> bool:

    def compare_normal_attribute(expected_value: str) -> bool:
        for actual_result in actual_results:
            if 'normal' in actual_result:
                if actual_result['normal'] == expected_value:
                    return True
        return False

    for expected_result in expected_results:
        if 'normal' in expected_result:
            if not compare_normal_attribute(expected_result['normal']):
                return False

    return True

The actual results are searched and if the expected value(s) are found, the function will return a truth value.

The full implementation is here: https://github.com/craigtrim/regression-framework/issues/2

Metadata

Release files for regression-framework 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for regression-framework 0.1.4
File Size Uploaded
regression-framework-0.1.4.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for regression-framework 0.1.4
File Interpreter ABI Platform
regression_framework-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 16.6 kB

Release files / regression-framework-0.1.4.tar.gz

Download URL regression-framework-0.1.4.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
68a1195d2989b2e0d954da16a4f7549c510d1afa674e779518290ecef1461458
BLAKE2b-256 checksum
How to use checksums
8e968ef87b41217236ff220adbb4ca3960fd8e8c9c18b447380f29a6d0ebbd8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.5 Windows/10

Release files / regression_framework-0.1.4-py3-none-any.whl

Download URL regression_framework-0.1.4-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
201c622eecbd7d4d78a76bdc2b90bff678f0e572c7b2ffe6e871ef8d6fac4511
BLAKE2b-256 checksum
How to use checksums
f02e0569033acb53173254221e72d14c1936b56f6147cbc5435f598483b33af5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.5 Windows/10

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page