Skip to main content

Define a user story in the business transaction DSL

Project description

https://raw.githubusercontent.com/dry-python/brand/master/logo/stories.png

travis codecov pyup codacy pypi docs gitter


The business transaction DSL

Installation

All released versions are hosted on the Python Package Index. You can install this package with following command.

pip install stories

Usage

stories provide a simple way to define a complex business scenario that include many processing steps.

from stories import story, argument, Success

class PurchaseProduct:

    @story
    @argument('user')
    @argument('product')
    @argument('shipment_details')
    def purchase(I):

        I.create_order
        I.calculate_price
        I.request_payment
        I.notify_user

    def create_order(self, ctx):

        return Success(order=Order.objects.create(user=ctx.user, product=ctx.product))

    def calculate_price(self, ctx):

        return Success(...

This code style allow you clearly separate actual business scenario from implementation details.

License

Dependencies library is offered under the two clause BSD license.

Changelog

0.9 (2018-11-28)

  • Enforce I noun with non callable attributes in the story definition.

  • Context is passed as an argument into story step methods.

  • Pass real class instances into step method.

  • Show story execution path in the Context representation.

  • Add Sentry, Py.test and Django Debug Toolbar plugins with Context reporter built in.

  • Raise an exception on Failure when the story was called directly.

  • Support iterable protocol in the Context class.

  • Add Failure reason.

  • Fix Skip result behavior in deeper sub-story hierarchy.

0.8 (2018-05-12)

  • Add dir() and repr() support to the context class.

  • Failed result holds a link to the context.

0.7 (2018-05-06)

  • Add run interface to the story.

0.6 (2018-04-19)

  • Representation methods for story, context and point result classes.

  • Python 2 support.

0.5 (2018-04-07)

  • Do not execute nested stories of the skipped story.

0.4 (2018-04-07)

  • Package was rewritten with linearization algorithm.

  • Skip result was added to finish nested stories without finish the caller.

0.0.3 (2018-04-06)

  • Nested stories support.

0.0.2 (2018-04-03)

  • Fix class and instance attribute access.

  • Validate return values.

  • Make context append only.

0.0.1 (2018-04-02)

  • Initial release.

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

stories-0.9.tar.gz (9.1 kB view hashes)

Uploaded Source

Built Distributions

stories-0.9-py3-none-any.whl (12.6 kB view hashes)

Uploaded Python 3

stories-0.9-py2-none-any.whl (13.4 kB view hashes)

Uploaded Python 2

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