canonical / canonical/pytest-interface-tester

simplify the testing API

Open
#16 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
1
Forks
5
Avg merge
3d 1h
Merged PRs (30d)
1

Description

as it stands, the testing API is too generic.

you write:
```
t = Tester(state_in=scenario.State)
t.run("foo-relation-changed")
```

whereas:
1) the only part of the state that the test should be concerned about is a single relation
2) the relation endpoint, and therefore the name of the event we are running, is not owned by the test either, but by the charm being tested.

Proposal:

consider cleaning up the API accordingly
```
from interface_tester import Relation
t = Tester(relation_in=Relation(remote_app_data={...}))
t.run_relation_changed()
...
```

This requires:

0) replacing `state_in` with `relation_in` in Tester; use relation_in to construct the usual state_in
1) adding a dedicated Relation subclass that gets rid of the 'endpoint' argument so the user doesn't even need to think about this. Because unfortunately, `endpoint` is the only mandatory arg to scenario.state.Relation :D
2) replacing generic `run()` with `run_relation_changed` and similar for other event types.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the Tester API and the existing interface_tester integration with scenario.State and scenario.state.Relation. Trace how state_in and run() currently construct and dispatch events. Done means relation_in builds the expected state, a dedicated Relation avoids requiring endpoint, and relation-specific event methods replace the generic run() API without breaking the documented usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience, testing-qa
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.