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
Metadata
Release files for ascender-spectests 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ascender_spectests-0.1.1.tar.gz | 3.6 kB | Without provenance | Details for ascender_spectests-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ascender_spectests-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for ascender_spectests-0.1.1-py3-none-any.whl |
Total release size: 9.5 kB
Release files / ascender_spectests-0.1.1.tar.gz
| Download URL | ascender_spectests-0.1.1.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3bb6df6e148e745d1ff98015e349dbcc552e536a671a85843067291683280eec
|
|
BLAKE2b-256 checksum How to use checksums |
1327cca7547e722080a493347a01b47c9e3faaf089c31f223ebc53444dfa72fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.11.13 Linux/6.15.5-arch1-1
|
Release files / ascender_spectests-0.1.1-py3-none-any.whl
| Download URL | ascender_spectests-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68cbbabde2c33bdc7c8b04bbfed43082a1839d787dfde280d00d43e242cf159c
|
|
BLAKE2b-256 checksum How to use checksums |
77d977767fc71bcc9bbbf6d800ede31dd2e162ac34e30bc68763126a099efd70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.11.13 Linux/6.15.5-arch1-1
|
Security for ascender-spectests 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.