Skip to main content

This library provides a set of utilities and tools for testing your ascender framework project and performing unit tests on your code. It supports Ascender Framework's DI (Dependency Injection) and provides a way to mock dependencies for testing purposes.

Project description

Ascender Specification Tests

This library provides a set of utilities and tools for testing your ascender framework project and performing unit tests on your code.

It supports Ascender Framework's DI (Dependency Injection) and provides a way to mock dependencies for testing purposes.

Features

  • Mocking of dependencies
  • Unit testing utilities
  • Integration with Ascender Framework's DI system
  • Easy setup for testing Ascender projects
  • HTTP client utilities (although you could use ascender.common.HTTPClient)

Installation

To install the Ascender Specification Tests library, you can use the following command:

poetry add ascender-spectests

Usage

To use the Ascender Specification Tests library in your project, you can import the necessary modules and define test cases using the provided utilities. Here's a simple example:

from spectests import TestingCase, AscSpecificationInterface
from unittest import AsyncTestCase


@TestingCase(
   imports=[
      # define your dependency injection imports here.
   ],
   providers=[
      # define your service providers here.
   ],
)
class MyTestCase(AsyncTestCase, AscSpecificationInterface):
   async def setUp(self):
      # Setup code here, e.g., initializing services or mocking dependencies
      print(self.injector) # Access to the DI injector of the current TestingCase scope (including imports and providers)

    async def test_example(self):
        # Assert
        result = "expected_value"
        self.assertEqual(result, 'expected_value')

Now to use it you have to provide the spectests in bootstrap.py file of your ascender project:

from ascender.core import IBootstrap
from ascender.core.cli import provideCLI
from spectests import provideSpecTests

appBootstrap: IBootstrap = {
    "providers": [
         provideRouter(routes),
         provideSpecTests(
            {
               "type": "specsuite",
               "spec": MyTestCase,  # Your test case class
               "methods": ["test_example"],  # List of methods to run as tests (not allowed to provide if type is "autospec")
            }
         ),  # Add this line to include the spec tests
         provideCLI(SpecTestsCLI)
    ]
}

Running Tests

To run the tests defined in your Ascender Specification Tests, you can use the following command:

ascender run tests start

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

ascender_spectests-0.1.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ascender_spectests-0.1.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file ascender_spectests-0.1.1.tar.gz.

File metadata

  • Download URL: ascender_spectests-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.13 Linux/6.15.5-arch1-1

File hashes

Hashes for ascender_spectests-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3bb6df6e148e745d1ff98015e349dbcc552e536a671a85843067291683280eec
MD5 a6d65851424405052f41cfde130a39b4
BLAKE2b-256 1327cca7547e722080a493347a01b47c9e3faaf089c31f223ebc53444dfa72fb

See more details on using hashes here.

File details

Details for the file ascender_spectests-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ascender_spectests-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.13 Linux/6.15.5-arch1-1

File hashes

Hashes for ascender_spectests-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 68cbbabde2c33bdc7c8b04bbfed43082a1839d787dfde280d00d43e242cf159c
MD5 70598704c92e2e6bffcf1891200c9a29
BLAKE2b-256 77d977767fc71bcc9bbbf6d800ede31dd2e162ac34e30bc68763126a099efd70

See more details on using hashes here.

Supported by

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