# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright 2016 Continuum Analytics, Inc.
#
# May be copied and distributed freely only as part of an Anaconda or
# Miniconda installation.
# -----------------------------------------------------------------------------
import os.path
import glob

from click.testing import CliRunner

from .base import FIXTURES

from anaconda_enterprise.cli.internal import yaml
from anaconda_enterprise.cli.main import group


def test_import_with_dry_run():
    """This test will not upload anything as there are files in the fixture,
    but it will generate a yaml which can then be checked.
    """
    runner = CliRunner()

    dumppath = os.path.join(FIXTURES, 'site-dump')

    users = glob.glob(os.path.join(dumppath, "*"))

    result = runner.invoke(group, ['admin', 'import'] + users + ['--dry-run', 'True'])
    assert result.exit_code == 0

    data = yaml.load(result.output)
    assert data
    assert len(data["accounts"]) == 3
