Repository: canonical/operator
Pull request #355 (2020-06-30 21:52:34)

readme tweaks (including link to the api docs)


Patch:
diff --git a/README.md b/README.md
index 3b4e63f..0236749 100644
--- a/README.md
+++ b/README.md
@@ -109,14 +109,15 @@ self.assertEqual(harness.charm. ...)
 If you need help, have ideas, or would just like to chat with us, reach out on
 IRC: we're in [#smooth-operator] on freenode (or try the [webchat]).
 
-We also pay attention to Juju's [discourse], but currently we don't actively
-post there outside of our little corner of the [docs]; most discussion at this
-stage is on IRC.
+We also pay attention to Juju's [discourse]; most discussion at this
+stage is on IRC, however.
+
+You can also deep dive into the [API docs] if that's your thing.
 
 [webchat]: https://webchat.freenode.net/#smooth-operator
 [#smooth-operator]: irc://chat.freenode.net/%23smooth-operator
 [discourse]: https://discourse.juju.is/c/charming
-[docs]: https://discourse.juju.is/c/docs/operator-framework
+[API docs]: https://ops.rtfd.io/
 
 ## Operator Framework development
 
diff --git a/ops/lib/__init__.py b/ops/lib/__init__.py
index edb9fca..b69ce0a 100644
--- a/ops/lib/__init__.py
+++ b/ops/lib/__init__.py
@@ -113,7 +113,7 @@ def _find_all_specs(path):
             if finder is None or not hasattr(finder, 'find_spec'):
                 continue
             for lib_dir in lib_dirs:
-                spec = finder.find_spec(lib_dir)
+                spec = finder.find_spec("{}.opslib.{}".format(top_dir, lib_dir))
                 if spec is None:
                     continue
                 if spec.loader is None:
diff --git a/ops/version.py b/ops/version.py
index 76db35a..15e5478 100644
--- a/ops/version.py
+++ b/ops/version.py
@@ -17,7 +17,7 @@ from pathlib import Path
 
 __all__ = ('version',)
 
-_FALLBACK = '0.7'  # this gets bumped after release
+_FALLBACK = '0.8'  # this gets bumped after release
 
 
 def _get_version():


Test patch:
diff --git a/test/test_lib.py b/test/test_lib.py
index 7e9af85..6aa5b06 100644
--- a/test/test_lib.py
+++ b/test/test_lib.py
@@ -520,6 +520,37 @@ class TestLibFunctional(TestCase):
         baz = ops.lib.use('baz', 2, 'alice@example.com')
         self.assertEqual(baz.LIBAPI, 2)
 
+    def _test_submodule(self, *, relative=False):
+        tmpdir = self._mkdtemp()
+        sys.path = [tmpdir]
+
+        path = _mklib(tmpdir, "foo", "bar")
+        path.write_text(dedent("""
+        LIBNAME = "baz"
+        LIBAPI = 2
+        LIBPATCH = 42
+        LIBAUTHOR = "alice@example.com"
+
+        from {} import quux
+        """).format("." if relative else "foo.opslib.bar"))
+        (path.parent / 'quux.py').write_text(dedent("""
+        this = 42
+        """))
+
+        # reset
+        ops.lib.autoimport()
+
+        # sanity check that ops.lib.use works
+        baz = ops.lib.use('baz', 2, 'alice@example.com')
+        self.assertEqual(baz.LIBAPI, 2)
+        self.assertEqual(baz.quux.this, 42)
+
+    def test_submodule_absolute(self):
+        self._test_submodule(relative=False)
+
+    def test_submodule_relative(self):
+        self._test_submodule(relative=True)
+
     def test_others_found(self):
         tmpdir = self._mkdtemp()
         sys.path = [tmpdir]