# Copyright (c) 2022, Xhive Global Ltd. and Contributors
# License: MIT. See LICENSE
import xhiveframework
from xhiveframework.config import get_modules_from_all_apps_for_user
from xhiveframework.tests.utils import XhiveFrameworkTestCase


class TestConfig(XhiveFrameworkTestCase):
	def test_get_modules(self):
		xhiveframework_modules = xhiveframework.get_all("Module Def", filters={"app_name": "xhiveframework"}, pluck="name")
		all_modules_data = get_modules_from_all_apps_for_user()
		first_module_entry = all_modules_data[0]
		all_modules = [x["module_name"] for x in all_modules_data]
		self.assertIn("links", first_module_entry)
		self.assertIsInstance(all_modules_data, list)
		self.assertFalse([x for x in xhiveframework_modules if x not in all_modules])
