# Path: datarobot_batch_scoring/utils.py
# def get_config_file():
#     """
#     Lookup for config file at user home directory or working directory.
#     Returns
#     -------
#     str or None
#         Path to config file or None if it not exists.
#     """
#     home_path = path_join(expanduser('~'), CONFIG_FILENAME)
#     cwd_path = path_join(getcwd(), CONFIG_FILENAME)
#     if isfile(cwd_path):
#         return cwd_path
#     elif isfile(home_path):
#         return home_path
#     return None
# 
# CONFIG_FILENAME = 'batch_scoring.ini'
# 
# def parse_config_file(file_path):
#     config = ConfigParser()
#     config.read(file_path)
#     if 'batch_scoring' not in config.sections():
#         #  We are return empty dict, because there is nothing in this file
#         #  that related to arguments to batch scoring.
#         return {}
#     parsed_dict = dict(config.items('batch_scoring'))
#     return config_validator(parsed_dict)
# 
# Path: datarobot_batch_scoring/main.py
# def main(argv=sys.argv[1:]):
#     return _main(argv, deployment_aware=False)
# 
# def main_deployment_aware(argv=sys.argv[1:]):
#     return _main(argv, deployment_aware=True)


import os
import textwrap
import mock
import pytest
from tempfile import NamedTemporaryFile
from datarobot_batch_scoring.utils import (get_config_file,
                                           CONFIG_FILENAME,
                                           parse_config_file)
from datarobot_batch_scoring.main import (
    main as batch_scoring_main, main_deployment_aware)
def create_file_and_clean_it(filename):
    try:
        with open(filename, 'w'):
            yield

    finally:
        os.remove(filename)


@pytest.yield_fixture
def config_file_in_home_dir():
    filename = os.path.join(
        os.path.expanduser('~'),
        CONFIG_FILENAME,
    )
    for _ in create_file_and_clean_it(filename):
        yield filename


@pytest.yield_fixture
def config_file_in_current_dir():
    filename = os.path.join(
        os.getcwd(),
        CONFIG_FILENAME,
    )
    for _ in create_file_and_clean_it(filename):
        yield filename


def test_no_file_is_ok():

# Path: datarobot_batch_scoring/utils.py
# def get_config_file():
#     """
#     Lookup for config file at user home directory or working directory.
#     Returns
#     -------
#     str or None
#         Path to config file or None if it not exists.
#     """
#     home_path = path_join(expanduser('~'), CONFIG_FILENAME)
#     cwd_path = path_join(getcwd(), CONFIG_FILENAME)
#     if isfile(cwd_path):
#         return cwd_path
#     elif isfile(home_path):
#         return home_path
#     return None
# 
# CONFIG_FILENAME = 'batch_scoring.ini'
# 
# def parse_config_file(file_path):
#     config = ConfigParser()
#     config.read(file_path)
#     if 'batch_scoring' not in config.sections():
#         #  We are return empty dict, because there is nothing in this file
#         #  that related to arguments to batch scoring.
#         return {}
#     parsed_dict = dict(config.items('batch_scoring'))
#     return config_validator(parsed_dict)
# 
# Path: datarobot_batch_scoring/main.py
# def main(argv=sys.argv[1:]):
#     return _main(argv, deployment_aware=False)
# 
# def main_deployment_aware(argv=sys.argv[1:]):
#     return _main(argv, deployment_aware=True)


# Path: tests/test_conf_file.py
import os
import textwrap
import mock
import pytest
from tempfile import NamedTemporaryFile
from datarobot_batch_scoring.utils import (get_config_file,
                                           CONFIG_FILENAME,
                                           parse_config_file)
from datarobot_batch_scoring.main import (
    main as batch_scoring_main, main_deployment_aware)

def create_file_and_clean_it(filename):
    try:
        with open(filename, 'w'):
            yield

    finally:
        os.remove(filename)


@pytest.yield_fixture
def config_file_in_home_dir():
    filename = os.path.join(
        os.path.expanduser('~'),
        CONFIG_FILENAME,
    )
    for _ in create_file_and_clean_it(filename):
        yield filename


@pytest.yield_fixture
def config_file_in_current_dir():
    filename = os.path.join(
        os.getcwd(),
        CONFIG_FILENAME,
    )
    for _ in create_file_and_clean_it(filename):
        yield filename


def test_no_file_is_ok():

    assert get_config_file() is None