-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the code compatible with Python 2
- Loading branch information
1 parent
ff3b617
commit 0fb5d0d
Showing
8 changed files
with
80 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
dist | ||
env | ||
__pycache__ | ||
*.pyc | ||
.coverage | ||
.tox | ||
AUTHORS | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
Charm Test | ||
========== | ||
|
||
.. image:: https://img.shields.io/pypi/v/charm-test.svg | ||
:target: https://pypi.python.org/pypi/charm-test | ||
:alt: Latest Version | ||
|
||
.. image:: https://travis-ci.org/freeekanayaka/charm-test.svg?branch=master | ||
:target: https://travis-ci.org/freeekanayaka/charm-test | ||
:alt: Build Status | ||
|
||
.. image:: https://coveralls.io/repos/github/freeekanayaka/charm-test/badge.svg?branch=master | ||
:target: https://coveralls.io/github/freeekanayaka/charm-test?branch=master | ||
:alt: Coverage | ||
|
||
This package sports a collection of helpers for unit-testing Juju charms. | ||
|
||
In particular, it extends systemfixtures_ by faking out hook tools | ||
processes (`config-get`, `juju-log`, etc), so authors have a complete suite | ||
of fakes for the typical "boundaries" of a Juju charm. | ||
|
||
.. code:: python | ||
>>> from testtools.matchers import DirExists | ||
>>> | ||
>>> from charmtest import CharmTest | ||
>>> | ||
>>> from charmhelpers.core import hookenv | ||
>>> | ||
>>> | ||
>>> def example_charm_logic(): | ||
... return { | ||
... "service-name": hookenv.service_name(), | ||
... "local-unit": hookenv.local_unit(), | ||
... "charm-dir": hookenv.charm_dir(), | ||
... } | ||
>>> | ||
>>> | ||
>>> class ExampleCharmTest(CharmTest): | ||
... | ||
... def test_charm_logic(self): | ||
... result = example_charm_logic() | ||
... self.assertEqual("test", result["service-name"]) | ||
... self.assertEqual("test/0", result["local-unit"]) | ||
... self.assertThat(result["charm-dir"], DirExists()) | ||
>>> | ||
>>> | ||
>>> ExampleCharmTest(methodName="test_charm_logic").run().wasSuccessful() | ||
True | ||
Support and Documentation | ||
------------------------- | ||
|
||
See the `online documentation <http://pythonhosted.org/charm-test/>`_ for | ||
a complete reference. | ||
|
||
Developing and Contributing | ||
--------------------------- | ||
|
||
See the `GitHub project <https://github.com/freeekanayaka/charm-test>`_. Bugs | ||
can be filed in the issues tracker. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import os | ||
|
||
|
||
def find_code_dir(): | ||
directory = os.getcwd() | ||
while directory != "/": | ||
if os.path.exists(os.path.join(directory, "metadata.yaml")): | ||
return directory | ||
else: # pragma: no cover | ||
raise RuntimeError("This doesn't seem to be a charm code tree") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters