# type: test
# title: scan all plugins
# description: scan module_list for meta infos
# config:
#    { name: scan, value: 1, type: bool }
# version: 0.5
# 
# 
import os
import sys
import pytest
import pluginconf
import pkgutil
import test.all_plugin_meta

# fix oourselves, cause pytest tampers with it too
@pytest.fixture
def init():
    pluginconf.plugin_base = ["test", os.path.dirname(__file__), "."]
    pluginconf.module_base = "all_plugin_meta"
    #print(os.getcwd())

def pktutil():
    # for comparison
    assert len(list(pkgutil.iter_modules(["."]))) >= 5

def ls(init):
    assert len(pluginconf.module_list()) >= 5

def scan_test():
    infos = pluginconf.all_plugin_meta()
    #print(infos)
    assert set(infos.keys()) & {
        'all_plugin_meta', 'basic', 'config', 'pyz', 'sources'
    }
    assert infos["all_plugin_meta"]["version"] == "0.5"
