# Path: scripnix/util/common.py
# HERE = os.path.abspath(os.path.dirname(__file__))
# BASE_CONFIG_DIR = os.path.abspath(os.path.join(HERE, "../conf"))
# ROOT_CONFIG_DIR = "/etc/scripnix"
# USER_CONFIG_DIR = os.path.expanduser("~/.scripnix")
# EXCEPTION_INDENT = len("Error: ")
# def check_root_user(command_name):
# def hostname():
# def is_root_user():
# def join_exceptions(exceptions):
# def natural_sort_key(key):
# def operating_system(translate=True):
# def config_values(*args):
#     def read_file_configuration(path, file_name, is_required):
# 
# Path: tests/common.py
# def platform_name():
#     # noinspection PyUnresolvedReferences
#     return os.uname().sysname.lower()  # A different method from that used by operating_system().


import platform
import pytest
from click import ClickException
from scripnix.util import common
from .common import platform_name


def test_is_root_user():
    assert not common.is_root_user()


@pytest.mark.parametrize('exceptions,expected', [
    ([], ""),
    (["foo"], "foo"),
    (["foo", "bar"], "foo\n       bar"),
    (["foo", "bar", "bat"], "foo\n       bar\n       bat"),
])
def test_join_exceptions(exceptions, expected):
    exceptions_copy = exceptions[:]
    assert common.join_exceptions(exceptions=exceptions) == expected
    assert exceptions_copy == exceptions


@pytest.mark.parametrize('key,expected', [
    ("", (-1, "")),
    ("0", (0, "")),
    ("1", (1, "")),
    ("foo", (-1, "foo")),
    ("0bar", (0, "bar")),
    ("2bar", (2, "bar")),
    ("bat3", (-1, "bat3")),
    ("47baz", (47, "baz")),
    ("101.325kp", (101, ".325kp")),
])
def test_natural_sort_key(key, expected):

# Path: scripnix/util/common.py
# HERE = os.path.abspath(os.path.dirname(__file__))
# BASE_CONFIG_DIR = os.path.abspath(os.path.join(HERE, "../conf"))
# ROOT_CONFIG_DIR = "/etc/scripnix"
# USER_CONFIG_DIR = os.path.expanduser("~/.scripnix")
# EXCEPTION_INDENT = len("Error: ")
# def check_root_user(command_name):
# def hostname():
# def is_root_user():
# def join_exceptions(exceptions):
# def natural_sort_key(key):
# def operating_system(translate=True):
# def config_values(*args):
#     def read_file_configuration(path, file_name, is_required):
# 
# Path: tests/common.py
# def platform_name():
#     # noinspection PyUnresolvedReferences
#     return os.uname().sysname.lower()  # A different method from that used by operating_system().


# Path: tests/test_common.py
import platform
import pytest
from click import ClickException
from scripnix.util import common
from .common import platform_name



def test_is_root_user():
    assert not common.is_root_user()


@pytest.mark.parametrize('exceptions,expected', [
    ([], ""),
    (["foo"], "foo"),
    (["foo", "bar"], "foo\n       bar"),
    (["foo", "bar", "bat"], "foo\n       bar\n       bat"),
])
def test_join_exceptions(exceptions, expected):
    exceptions_copy = exceptions[:]
    assert common.join_exceptions(exceptions=exceptions) == expected
    assert exceptions_copy == exceptions


@pytest.mark.parametrize('key,expected', [
    ("", (-1, "")),
    ("0", (0, "")),
    ("1", (1, "")),
    ("foo", (-1, "foo")),
    ("0bar", (0, "bar")),
    ("2bar", (2, "bar")),
    ("bat3", (-1, "bat3")),
    ("47baz", (47, "baz")),
    ("101.325kp", (101, ".325kp")),
])
def test_natural_sort_key(key, expected):

    assert common.natural_sort_key(key) == expected