from cobwebs.config import get_config, import_plugin


def test_get_config():
    global_config = get_config(confname="conf.yaml", confdir="conf")
    assert isinstance(global_config, dict)
    assert "main" in global_config
    assert "templates" in global_config['main']
    assert "plugins" in global_config['main']
    assert "mq_driver" in global_config['main']
    assert "logging" in global_config


def test_import_plugin():
    global_config = get_config(confname="conf.yaml", confdir="conf")
    plugins = import_plugin(global_config)
    assert isinstance(plugins, dict)

@@ -1,8 +1,60 @@
+import os%0Aimport tempfile%0Afrom unittest import mock%0A
 from cob
@@ -98,16 +98,225 @@
 _plugin%0A
+import pytest%0A%0A%0A@pytest.fixture(scope=%22session%22)%0Adef tmp_config_file(tmpdir_factory):%0A    fn = tmpdir_factory.mktemp('data').join('conf.yaml')%0A    open(str(fn), %22w%22).write(str(config_test))%0A    return str(fn)%0A
 %0A%0Adef te
@@ -329,16 +329,31 @@
 _config(
+tmp_config_file
 ):%0A    g
@@ -391,35 +391,23 @@
 ame=
-%22conf.yaml%22, confdir=%22conf%22
+tmp_config_file
 )%0A  
@@ -687,16 +687,31 @@
 _plugin(
+tmp_config_file
 ):%0A    g
@@ -740,122 +740,939 @@
 fig(
-confname=%22conf.yaml%22, confdir=%22conf%22)%0A    plugins = import_plugin(global_config)%0A    assert isinstance(plugins, dict)%0A
+tmp_config_file)%0A    plugins = import_plugin(global_config)%0A    assert isinstance(plugins, dict)%0A%0A%0Aconfig_test = %22%22%22main:%0A  templates: %22src/apiviewer/static/templates/%22%0A  plugins: %22src/spider/spider/plugins/%22%0A  mq_driver: cobwebs.mq.backends.rabbitmq%0A  mq_host: localhost%0A%0Alogging:%0A  version: 1%0A%0A  formatters:%0A    brief:%0A      format: %22%25(levelname)s %25(name)s %25(message)-30s%22%0A    custom:%0A      format: %22%25(asctime)-15s %25(levelname)s %25(name)s %25(message)s%22%0A%0A  handlers:%0A    console:%0A      class : logging.StreamHandler%0A      formatter: brief%0A      level   : INFO%0A      stream  : ext://sys.stdout%0A    file:%0A      class : logging.handlers.RotatingFileHandler%0A      formatter: custom%0A      level   : DEBUG%0A      filename: /tmp/logconfig.log%0A      maxBytes: 1048576%0A      backupCount: 3%0A%0A  loggers:%0A    spider:%0A      level: DEBUG%0A      handlers: %5Bfile%5D%0A      propagate: no%0A%0A  root:%0A    level: INFO%0A    handlers: %5Bfile%5D%0A%22%22%22%0A%0A#save_config_file()

Update tests