# Path: app/configs.py
# APP_PATH = os.path.dirname(os.path.abspath(__file__))
# PROJECT_PATH = os.path.dirname(APP_PATH)
#     EC = EnjoliverConfig("%s/configs.yaml" % os.path.dirname(__file__))
# class EnjoliverConfig:
#     def config_override(self, key: str, default):
#     def __init__(self, yaml_full_path=os.getenv("ENJOLIVER_CONFIGS_YAML",
#                                                 "%s/configs.yaml" % APP_PATH), importer=""):


import os
import unittest
import sys
from app import (
    configs,
)
    matchbox = os.getenv("CHECK_MATCHBOX_PATH", "%s/matchbox" % cwd)
    assets = "%s/assets" % matchbox

    def test_discoveryC(self):
        rule = "%s/%s/serve" % (self.assets, self.test_discoveryC.__name__.replace("test_", ""))
        list_dir = os.listdir(rule)
        self.assertIn("discoveryC", list_dir)

    def test_enjoliver_agent(self):
        rule = "%s/%s/serve" % (self.assets, self.test_enjoliver_agent.__name__.replace("test_", "").replace("_", "-"))
        list_dir = os.listdir(rule)
        self.assertIn("enjoliver-agent", list_dir)

    def test_coreos(self):
        rule = "%s/%s/serve" % (self.assets, self.test_coreos.__name__.replace("test_", ""))
        list_dir = os.listdir(rule)
        self.assertIn("coreos_production_image.bin.bz2", list_dir)
        self.assertIn("coreos_production_image.bin.bz2.sig", list_dir)
        self.assertIn("coreos_production_image_verity.txt", list_dir)
        self.assertIn("coreos_production_pxe.vmlinuz", list_dir)
        self.assertIn("coreos_production_pxe.vmlinuz.sig", list_dir)
        self.assertIn("coreos_production_pxe_image.cpio.gz", list_dir)
        self.assertIn("coreos_production_pxe_image.cpio.gz.sig", list_dir)
        self.assertIn("version.txt", list_dir)


@unittest.skipIf(os.getenv("SKIP_ACSERVER"), "skip acserver storage")
class TestValidateAcserverStorage(unittest.TestCase):
    cwd = os.path.dirname(os.path.abspath(__file__))
    acserver_d = os.path.join(cwd, "runtime/acserver.d/enjoliver.local")

# Path: app/configs.py
# APP_PATH = os.path.dirname(os.path.abspath(__file__))
# PROJECT_PATH = os.path.dirname(APP_PATH)
#     EC = EnjoliverConfig("%s/configs.yaml" % os.path.dirname(__file__))
# class EnjoliverConfig:
#     def config_override(self, key: str, default):
#     def __init__(self, yaml_full_path=os.getenv("ENJOLIVER_CONFIGS_YAML",
#                                                 "%s/configs.yaml" % APP_PATH), importer=""):


# Path: validate.py
import os
import unittest
import sys
from app import (
    configs,
)

    matchbox = os.getenv("CHECK_MATCHBOX_PATH", "%s/matchbox" % cwd)
    assets = "%s/assets" % matchbox

    def test_discoveryC(self):
        rule = "%s/%s/serve" % (self.assets, self.test_discoveryC.__name__.replace("test_", ""))
        list_dir = os.listdir(rule)
        self.assertIn("discoveryC", list_dir)

    def test_enjoliver_agent(self):
        rule = "%s/%s/serve" % (self.assets, self.test_enjoliver_agent.__name__.replace("test_", "").replace("_", "-"))
        list_dir = os.listdir(rule)
        self.assertIn("enjoliver-agent", list_dir)

    def test_coreos(self):
        rule = "%s/%s/serve" % (self.assets, self.test_coreos.__name__.replace("test_", ""))
        list_dir = os.listdir(rule)
        self.assertIn("coreos_production_image.bin.bz2", list_dir)
        self.assertIn("coreos_production_image.bin.bz2.sig", list_dir)
        self.assertIn("coreos_production_image_verity.txt", list_dir)
        self.assertIn("coreos_production_pxe.vmlinuz", list_dir)
        self.assertIn("coreos_production_pxe.vmlinuz.sig", list_dir)
        self.assertIn("coreos_production_pxe_image.cpio.gz", list_dir)
        self.assertIn("coreos_production_pxe_image.cpio.gz.sig", list_dir)
        self.assertIn("version.txt", list_dir)


@unittest.skipIf(os.getenv("SKIP_ACSERVER"), "skip acserver storage")
class TestValidateAcserverStorage(unittest.TestCase):
    cwd = os.path.dirname(os.path.abspath(__file__))
    acserver_d = os.path.join(cwd, "runtime/acserver.d/enjoliver.local")

    ec = configs.EnjoliverConfig(importer=__file__)