Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
... to be actual unit tests (as opposed to being integration tests
that tests the actual setup in which it's being run)
  • Loading branch information
cderici committed Oct 5, 2021
1 parent 15eed35 commit 2106cd3
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
import os
import unittest

from pathlib import Path
from juju.utils import juju_config_dir, juju_ssh_key_paths


def test_config_dir():
config_dir = juju_config_dir()
assert os.path.exists(config_dir)
assert os.path.isdir(config_dir)
class TestDirResolve(unittest.TestCase):
def test_config_dir(self):
config_dir = juju_config_dir()
assert 'local/share/juju' in config_dir

assert os.path.exists(os.path.join(config_dir, 'controllers.yaml'))


def test_juju_ssh_key_paths():
public, private = juju_ssh_key_paths()
assert os.path.exists(public)
assert os.path.isfile(public)

assert os.path.exists(private)
assert os.path.isfile(private)

with Path(public).open('r') as f:
assert "ssh-rsa" in f.read()

with Path(private).open('r') as g:
assert "PRIVATE KEY" in g.read()
def test_juju_ssh_key_paths(self):
public, private = juju_ssh_key_paths()
assert public.endswith('ssh/juju_id_rsa.pub')
assert private.endswith('ssh/juju_id_rsa')

0 comments on commit 2106cd3

Please sign in to comment.