Skip to main content

No project description provided

Project description

Derivation

Maintainability Test Coverage codecov Github Actions PyPI pyversions

Derivation is a flexible payload generating framework with highly-customizable patterns and rules which raise your efficiency significantly on test case implementation against complicated inputs.

Getting Started

Derivative

Derivative is the primary object which sorted out all of valid outputs meet the constraints.

The script below can be executed directly

from enum import Enum, auto
from operator import or_

from derivation.constraint import (
    MutuallyExclusiveConstraint,
    OccurrenceConstraint,
    PrerequisiteConstraint,
    TerminationConstraint,
)
from derivation.derivative import Derivative


class DerivativeEvent(Enum):
    @staticmethod
    def _generate_next_value_(name, start, count, last_values):
        return name.upper()


class DerivativeEventAlpha(DerivativeEvent):

    ESSENTIALS = auto()

    OPTIONAL_1 = auto()
    OPTIONAL_1_1 = auto()
    OPTIONAL_1_2 = auto()

    OPTIONAL_2 = auto()
    OPTIONAL_3 = auto()


EVENT_ALPHA = {event: {event.value: None} for event in DerivativeEventAlpha}

derivative = Derivative(
    EVENT_ALPHA,
    or_,
    (
        OccurrenceConstraint(
            (DerivativeEventAlpha.ESSENTIALS,),
            min_times=1,
            max_times=1,
        ),
        MutuallyExclusiveConstraint(
            (
                DerivativeEventAlpha.OPTIONAL_1,
                DerivativeEventAlpha.OPTIONAL_2,
                DerivativeEventAlpha.OPTIONAL_3,
            ),
        ),
        MutuallyExclusiveConstraint(
            (DerivativeEventAlpha.OPTIONAL_1_1, DerivativeEventAlpha.OPTIONAL_1_2),
        ),
        PrerequisiteConstraint(
            (DerivativeEventAlpha.OPTIONAL_1,),
            (DerivativeEventAlpha.OPTIONAL_1_1, DerivativeEventAlpha.OPTIONAL_1_2),
        ),
        TerminationConstraint(
            {
                DerivativeEventAlpha.OPTIONAL_1_1,
                DerivativeEventAlpha.OPTIONAL_1_2,
                DerivativeEventAlpha.OPTIONAL_2,
                DerivativeEventAlpha.OPTIONAL_3,
            },
        ),
    ),
)

for order, result in derivative.exhaustive():

    print(f"{order}\n{result}\n")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

derivation-0.3.0.tar.gz (5.5 kB view hashes)

Uploaded Source

Built Distribution

derivation-0.3.0-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page