# Path: teuthology/misc.py
# def get_distro_version(ctx):
#     """
#     Get the verstion of the distro that we are using (release number).
#     """
#     distro = get_distro(ctx)
#     if ctx.os_version is not None:
#         return str(ctx.os_version)
#     try:
#         os_version = ctx.config.get('os_version', DEFAULT_OS_VERSION[distro])
#     except AttributeError:
#         os_version = DEFAULT_OS_VERSION[distro]
#     return str(os_version)


from teuthology.misc import get_distro_version
class Mock:
    pass


class TestGetDistroVersion(object):

    def setup(self):
        self.fake_ctx = Mock()
        self.fake_ctx.config = {}
        self.fake_ctx_noarg = Mock()
        self.fake_ctx_noarg.config = {}
        self.fake_ctx_noarg.os_version = None
        self.fake_ctx.os_type = None
        self.fake_ctx_noarg.os_type = None

    def test_default_distro_version(self):
        # Default distro is ubuntu, default version of ubuntu is 20.04
        self.fake_ctx.os_version = None
        distroversion = get_distro_version(self.fake_ctx)
        assert distroversion == '20.04'

    def test_argument_version(self):
        self.fake_ctx.os_version = '13.04'
        distroversion = get_distro_version(self.fake_ctx)
        assert distroversion == '13.04'

    def test_teuth_config_version(self):
        #Argument takes precidence.
        self.fake_ctx.os_version = '13.04'
        self.fake_ctx.config = {'os_version': '13.10'}

# Path: teuthology/misc.py
# def get_distro_version(ctx):
#     """
#     Get the verstion of the distro that we are using (release number).
#     """
#     distro = get_distro(ctx)
#     if ctx.os_version is not None:
#         return str(ctx.os_version)
#     try:
#         os_version = ctx.config.get('os_version', DEFAULT_OS_VERSION[distro])
#     except AttributeError:
#         os_version = DEFAULT_OS_VERSION[distro]
#     return str(os_version)


# Path: teuthology/test/test_get_distro_version.py
from teuthology.misc import get_distro_version

class Mock:
    pass


class TestGetDistroVersion(object):

    def setup(self):
        self.fake_ctx = Mock()
        self.fake_ctx.config = {}
        self.fake_ctx_noarg = Mock()
        self.fake_ctx_noarg.config = {}
        self.fake_ctx_noarg.os_version = None
        self.fake_ctx.os_type = None
        self.fake_ctx_noarg.os_type = None

    def test_default_distro_version(self):
        # Default distro is ubuntu, default version of ubuntu is 20.04
        self.fake_ctx.os_version = None
        distroversion = get_distro_version(self.fake_ctx)
        assert distroversion == '20.04'

    def test_argument_version(self):
        self.fake_ctx.os_version = '13.04'
        distroversion = get_distro_version(self.fake_ctx)
        assert distroversion == '13.04'

    def test_teuth_config_version(self):
        #Argument takes precidence.
        self.fake_ctx.os_version = '13.04'
        self.fake_ctx.config = {'os_version': '13.10'}

        distroversion = get_distro_version(self.fake_ctx)