-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: remove dependency on ops.testing #190
refactor: remove dependency on ops.testing #190
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the TestingPebbleClient thing is a bit messy. Let's brainstorm a little bit during daily sync. I wonder if we can just wait till after this code lives in the ops repo?
Sure.
We can definitely do these in the opposite order, or in a single PR. However, the circular issue will still exist, unless we don't add Scenario's code in a new top-level location outside of ops (which is the cleanest for having multiple packages, but could be worked around), or we don't have both Harness and Scenario in the same For the Pebble test client, another option would be late importing. The Scenario test Pebble client could contain an |
We're going to move the existing |
69223f2
to
505f65f
Compare
This should be ok now, but it needs the ops change done first (and released) and then I've also assumed that #191 will get done first as well. I'll move it from draft after those. |
I've adjusted the PR so that it doesn't need to have the ops change released, because that would slow things down a lot and it would be great to get this piece finished. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Drat, I I think I accidentally merged my way out of this one getting a release :( |
The goal is that after doing
pip install ops[testing]
you can run code like:Basically: everything that Scenario exports will be available in the
ops.testing
namespace. This means that Scenario importing from theops.testing
namespace is problematic, because the imports end up being circular.To avoid this, ops has moved the actual Harness code into a new
ops._private.harness
module (ops.testing now just handles setting up the namespace). This PR adjusts for that change, importing fromops._private.harness
instead ofops.testing
.Rather than just switch to this and require ops 2.17, I've adjusted the imports to work for either case (ops 2.15+). This is messier, but avoids forcing to update their ops and also means that we don't need to wait for two ops releases (potentially two months) in order to make the second change there. There's already a bunch of code to handle other (nominally private) changes in ops 2.16 and 2.17, so a bit more doesn't seem to hurt (for a short time - it will be good to clear all this out soon).
In addition, Scenario already defined a
CharmType
type, so use that consistently rather than using that in some cases andops.testing.CharmType
in others.There's one technically breaking change:
ActionFailed
requires thestate
argument to be passed by keyword. Tests shouldn't be creatingActionFailed
objects so this should have no impact on anyone. This will make it easier to handle the clash between Harness'sActionFailed
and Scenario'sActionFailed
.