emmental/tests/test_gsetup.py

56 lines
2.3 KiB
Python

# Copyright 2022 (c) Anna Schumaker.
"""Test that the gi.repository has been configured correctly."""
import unittest
import pathlib
import emmental
import gi
class TestGSetup(unittest.TestCase):
"""GObject Introspection configuration test case."""
def test_require_version(self):
"""Check that gi.require_version() has been called."""
self.assertEqual(gi.get_required_version("Gtk"), "4.0")
self.assertEqual(gi.get_required_version("Adw"), "1")
def test_adw(self):
"""Check that libadwaita style has been set."""
style = gi.repository.Adw.StyleManager.get_default()
self.assertEqual(style.get_color_scheme(),
gi.repository.Adw.ColorScheme.DEFAULT)
def test_import(self):
"""Check that modules have been imported."""
self.assertIsNotNone(emmental.gsetup.gi)
def test_application_id(self):
"""Check that the application id is generated properly."""
self.assertEqual(emmental.gsetup.DEBUG_STR, "-debug")
self.assertEqual(emmental.gsetup.APPLICATION_ID,
"com.nowheycreamery.emmental-debug")
def test_css(self):
"""Check that our custom stylesheet is configured."""
path = pathlib.Path(emmental.__file__).parent / "emmental.css"
self.assertEqual(emmental.gsetup.CSS_FILE, path)
self.assertEqual(emmental.gsetup.CSS_PRIORITY,
gi.repository.Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
self.assertIsInstance(emmental.gsetup.CSS_PROVIDER,
gi.repository.Gtk.CssProvider)
def test_resource(self):
"""Check that emmental.resource has been loaded."""
path = pathlib.Path(emmental.__file__).parent.parent
path = path / "emmental.gresource"
self.assertEqual(emmental.gsetup.RESOURCE_PATH,
"/com/nowheycreamery/emmental")
icons = f"{emmental.gsetup.RESOURCE_PATH}/icons/scalable/apps"
self.assertEqual(emmental.gsetup.RESOURCE_ICONS, icons)
self.assertEqual(emmental.gsetup.RESOURCE_FILE, path)
self.assertTrue(emmental.gsetup.RESOURCE_FILE.is_file())
self.assertIsInstance(emmental.gsetup.RESOURCE,
gi.repository.Gio.Resource)