I am writing tests for my Dagger module now. Here's what the directory structure looks like
tree -L 2 -a
.
├── .dagger
│ ├── .gitattributes
│ ├── .gitignore
│ ├── pyproject.toml
│ ├── sdk
│ ├── src
│ └── uv.lock
├── LICENSE
├── README.md
├── dagger.json
└── tests
├── .gitattributes
├── .gitignore
├── dagger.json
├── pyproject.toml
├── sdk
├── src
└── uv.lock
src/localstack_dagger_module/main.py has this basic code:
@object_type
class LocalstackDaggerModule:
@function
def serve(
self,
...
) -> dagger.Service:
...
# Return as service
return container.as_service()
I am adding tests for it in tests/src/tests/main.py as the docs recommend:
import dagger
from dagger import dag, function, object_type
import requests
@object_type
class Tests:
@function
async def test_localstack_health(self) -> str:
"""Test if LocalStack starts and responds to health check"""
# Start LocalStack using the module
service = await dag.LocalstackDaggerModule().serve()
....
Running this from root results in
dagger call test-localstack-health
✔ connect 0.2s
✔ load module 0.8s
✘ parsing command line arguments 0.0s
! unknown command "test-localstack-health" for "dagger call"
and within tests dir it results in
dagger call test-localstack-health
✔ connect 0.2s
✔ load module 0.7s
✔ parsing command line arguments 0.0s
✔ tests: Tests! 0.9s
✘ .testLocalstackHealth: String! 0.8s
! 'Client' object has no attribute 'LocalstackDaggerModule'
Pretty sure that I'm setting the directory structure wrong, but would love to get some help since I followed the docs itself: https://docs.dagger.io/api/module-tests/