# Path: conjureup/utils.py
# def chdir(directory):
# def run(cmd, **kwargs):
# def run_script(path, stderr=PIPE, stdout=PIPE):
# def run_attach(cmd, output_cb=None):
#     def last_ten_lines(s):
# async def arun(cmd, input=None, check=False, env=None, encoding='utf8',
#                stdin=PIPE, stdout=PIPE, stderr=PIPE, cb_stdout=None,
#                cb_stderr=None, **kwargs):
#         async def tstream(source_name, sink, ui_cb):
# def sentry_report(message=None, exc_info=None, tags=None, **kwargs):
# def _sentry_report(message=None, exc_info=None, tags=None, **kwargs):
# async def can_sudo(password=None):
# def juju_version():
# def snap_version():
# def send_msg(msg, label, color, attrs=['bold']):
# def info(msg):
# def error(msg):
# def warning(msg):
# def install_home():
# def juju_path():
# def mkdir(path):
# def _normalize_bundle(original_bundle, overlay_bundle):
# def merge_dicts(*dicts):
# def subtract_dicts(*dicts):
# def chown(path, user, group=None, recursive=False):
# def spew(path, data, owner=None):
# def slurp(path):
# def install_user():
# def set_chosen_spell(spell_name, spell_dir):
# def set_spell_metadata():
# def get_spell_metadata(spell):
# def __available_on_darwin(key):
# def find_spells():
# def find_addons_matching(key):
# def find_spells_matching(key):
# def get_options_whitelist(service_name):
# def gen_hash():
# def gen_model():
# def gen_cloud():
# def is_darwin():
# def is_linux():
# def is_valid_hostname(hostname):
# def set_terminal_title(title):
# def get_physical_network_interfaces():
# def get_physical_network_ipaddr(iface):
# def get_open_port():
#     def __init__(self, *args, **kwargs):
#     def __aiter__(self):
#     async def __anext__(self):
#     async def close(self):
#     def sanitize(self, key, value):
#         def _check_str(s):
#     def __init__(self):
# class IterQueue(asyncio.Queue):
# class SanitizeDataProcessor(SanitizePasswordsProcessor):
# class TestError(Exception):
# class SudoError(Exception):
# class UtilsHTTPError(Exception):
# 
# Path: test/helpers.py
# @contextmanager
# def test_loop():
#     old_loop = asyncio.get_event_loop()
#     new_loop = asyncio.new_event_loop()
#     try:
#         asyncio.set_event_loop(new_loop)
#         with _patch_events(new_loop):
#             yield new_loop
#     finally:
#         asyncio.set_event_loop(old_loop)
#         new_loop.close()


import asyncio
import logging
import unittest
from unittest.mock import patch
from conjureup import utils
from .helpers import test_loop
    def test_valid_hostnames(self):
        "Verify is_valid_hostname"

        hostnames = [
            'battlemidget.lol',
            'www.battlemidget.lol',
            'localhost',
            'localhost.localdomain',
            '_underscores-is_ok',
            'double--dash_is_ok'
        ]
        for hostname in hostnames:
            assert utils.is_valid_hostname(hostname)

    def test_invalid_hostnames(self):
        "Verify is_valid_hostname detects invalid hostnames"

        hostnames = [
            '-no-starting-dash.com',
            '.localhost',
            'localhost.no-end-dash-'
        ]
        for hostname in hostnames:
            assert not utils.is_valid_hostname(hostname)

    @patch.object(utils, 'juju_version')
    @patch.object(utils, 'app')
    def test_sentry_report(self, app, juju_version):
        # test task schedule
        flag = asyncio.Event()

# Path: conjureup/utils.py
# def chdir(directory):
# def run(cmd, **kwargs):
# def run_script(path, stderr=PIPE, stdout=PIPE):
# def run_attach(cmd, output_cb=None):
#     def last_ten_lines(s):
# async def arun(cmd, input=None, check=False, env=None, encoding='utf8',
#                stdin=PIPE, stdout=PIPE, stderr=PIPE, cb_stdout=None,
#                cb_stderr=None, **kwargs):
#         async def tstream(source_name, sink, ui_cb):
# def sentry_report(message=None, exc_info=None, tags=None, **kwargs):
# def _sentry_report(message=None, exc_info=None, tags=None, **kwargs):
# async def can_sudo(password=None):
# def juju_version():
# def snap_version():
# def send_msg(msg, label, color, attrs=['bold']):
# def info(msg):
# def error(msg):
# def warning(msg):
# def install_home():
# def juju_path():
# def mkdir(path):
# def _normalize_bundle(original_bundle, overlay_bundle):
# def merge_dicts(*dicts):
# def subtract_dicts(*dicts):
# def chown(path, user, group=None, recursive=False):
# def spew(path, data, owner=None):
# def slurp(path):
# def install_user():
# def set_chosen_spell(spell_name, spell_dir):
# def set_spell_metadata():
# def get_spell_metadata(spell):
# def __available_on_darwin(key):
# def find_spells():
# def find_addons_matching(key):
# def find_spells_matching(key):
# def get_options_whitelist(service_name):
# def gen_hash():
# def gen_model():
# def gen_cloud():
# def is_darwin():
# def is_linux():
# def is_valid_hostname(hostname):
# def set_terminal_title(title):
# def get_physical_network_interfaces():
# def get_physical_network_ipaddr(iface):
# def get_open_port():
#     def __init__(self, *args, **kwargs):
#     def __aiter__(self):
#     async def __anext__(self):
#     async def close(self):
#     def sanitize(self, key, value):
#         def _check_str(s):
#     def __init__(self):
# class IterQueue(asyncio.Queue):
# class SanitizeDataProcessor(SanitizePasswordsProcessor):
# class TestError(Exception):
# class SudoError(Exception):
# class UtilsHTTPError(Exception):
# 
# Path: test/helpers.py
# @contextmanager
# def test_loop():
#     old_loop = asyncio.get_event_loop()
#     new_loop = asyncio.new_event_loop()
#     try:
#         asyncio.set_event_loop(new_loop)
#         with _patch_events(new_loop):
#             yield new_loop
#     finally:
#         asyncio.set_event_loop(old_loop)
#         new_loop.close()


# Path: test/test_utils.py
import asyncio
import logging
import unittest
from unittest.mock import patch
from conjureup import utils
from .helpers import test_loop

    def test_valid_hostnames(self):
        "Verify is_valid_hostname"

        hostnames = [
            'battlemidget.lol',
            'www.battlemidget.lol',
            'localhost',
            'localhost.localdomain',
            '_underscores-is_ok',
            'double--dash_is_ok'
        ]
        for hostname in hostnames:
            assert utils.is_valid_hostname(hostname)

    def test_invalid_hostnames(self):
        "Verify is_valid_hostname detects invalid hostnames"

        hostnames = [
            '-no-starting-dash.com',
            '.localhost',
            'localhost.no-end-dash-'
        ]
        for hostname in hostnames:
            assert not utils.is_valid_hostname(hostname)

    @patch.object(utils, 'juju_version')
    @patch.object(utils, 'app')
    def test_sentry_report(self, app, juju_version):
        # test task schedule
        flag = asyncio.Event()

        with patch.object(utils, '_sentry_report',