Skip to main content

ascender-spectests

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.0.tar.gz (3.5 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.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ascender_spectests-0.1.0.tar.gz
  • Upload date:
  • Size: 3.5 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.0.tar.gz
Algorithm Hash digest
SHA256 0213dc708f2d42e8ca0478c1a79e55b9cf96335a6223ebada4743a2cb2e68502
MD5 9f4c9a684b3afdd6fc77810d2d0be937
BLAKE2b-256 e0a7498a77f2263c9cfe2d19792a54a783f44336959e3038c05b85a835223528

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ascender_spectests-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 40f913263306b3b3ef1842a199062d840705ae26cbd43deefa0969e51535f09b
MD5 51c6b6a449f8f9fc3156c8a981805e1b
BLAKE2b-256 c440a5ca253fa3d8f6976d0f1c71d486a292c77b1677884ada6b55a74454bc82

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