# Path: bifrost/cli.py
# VENV = "/opt/stack/bifrost"
# ANSIBLE = os.path.join(VENV, 'bin', 'ansible-playbook')
# COMMON_ENV = {
#     'VENV': VENV,
# }
# COMMON_PARAMS = [
#     '-e', 'bifrost_venv_dir=%s' % VENV,
# ]
# BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..'))
# PLAYBOOKS = os.path.join(BASE, 'playbooks')
# DEFAULT_BRANCH = 'master'
# def get_env(extra=None):
# def log(*message, only_if=True):
# def process_extra_vars(extra_vars):
# def ansible(playbook, inventory, verbose=False, env=None, extra_vars=None,
#             params_output_file=None, **params):
# def env_setup(args):
# def get_release(release):
# def cmd_testenv(args):
# def cmd_install(args):
# def cmd_enroll(args):
# def parse_args():
# def check_for_root():
# def main():


import os.path
import shutil
import tempfile
from unittest import mock
from bifrost import cli
from bifrost.tests import base




FILE_NO_BRANCH = """
[gerrit]
host=review.opendev.org
port=29418
project=openstack/bifrost.git
"""


FILE_WITH_BRANCH = """
[gerrit]
host=review.opendev.org
port=29418
project=openstack/bifrost.git
defaultbranch=stable/banana
"""


class TestGetRelease(base.TestCase):
    def setUp(self):
        super().setUp()
        self.temp_dir = tempfile.mkdtemp()
        self.addCleanup(lambda: shutil.rmtree(self.temp_dir))

    def test_provided(self):
        self.assertEqual('stable/ussuri', cli.get_release('ussuri'))
        self.assertEqual('stable/ussuri', cli.get_release('stable/ussuri'))

# Path: bifrost/cli.py
# VENV = "/opt/stack/bifrost"
# ANSIBLE = os.path.join(VENV, 'bin', 'ansible-playbook')
# COMMON_ENV = {
#     'VENV': VENV,
# }
# COMMON_PARAMS = [
#     '-e', 'bifrost_venv_dir=%s' % VENV,
# ]
# BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..'))
# PLAYBOOKS = os.path.join(BASE, 'playbooks')
# DEFAULT_BRANCH = 'master'
# def get_env(extra=None):
# def log(*message, only_if=True):
# def process_extra_vars(extra_vars):
# def ansible(playbook, inventory, verbose=False, env=None, extra_vars=None,
#             params_output_file=None, **params):
# def env_setup(args):
# def get_release(release):
# def cmd_testenv(args):
# def cmd_install(args):
# def cmd_enroll(args):
# def parse_args():
# def check_for_root():
# def main():


# Path: bifrost/tests/unit/test_cli.py
import os.path
import shutil
import tempfile
from unittest import mock
from bifrost import cli
from bifrost.tests import base





FILE_NO_BRANCH = """
[gerrit]
host=review.opendev.org
port=29418
project=openstack/bifrost.git
"""


FILE_WITH_BRANCH = """
[gerrit]
host=review.opendev.org
port=29418
project=openstack/bifrost.git
defaultbranch=stable/banana
"""


class TestGetRelease(base.TestCase):
    def setUp(self):
        super().setUp()
        self.temp_dir = tempfile.mkdtemp()
        self.addCleanup(lambda: shutil.rmtree(self.temp_dir))

    def test_provided(self):
        self.assertEqual('stable/ussuri', cli.get_release('ussuri'))
        self.assertEqual('stable/ussuri', cli.get_release('stable/ussuri'))

        self.assertEqual('master', cli.get_release('master'))