3
0
Fork 0

fix: format all code with black

and from now on should not deviate from that...
This commit is contained in:
Lance Edgar 2025-08-30 21:25:44 -05:00
parent 49f9a0228b
commit a6bb538ce9
59 changed files with 2762 additions and 2131 deletions

View file

@ -7,12 +7,12 @@ from wuttjamaican.testing import ConfigTestCase
class MockFooReport(mod.Report):
report_key = 'mock_foo'
report_key = "mock_foo"
report_title = "MOCK Report"
def make_data(self, params, **kwargs):
return [
{'foo': 'bar'},
{"foo": "bar"},
]
@ -35,15 +35,15 @@ class TestReportHandler(ConfigTestCase):
def test_get_report_modules(self):
# no providers, no report modules
with patch.object(self.app, 'providers', new={}):
with patch.object(self.app, "providers", new={}):
handler = self.make_handler()
self.assertEqual(handler.get_report_modules(), [])
# provider may specify modules as list
providers = {
'wuttatest': MagicMock(report_modules=['wuttjamaican.reports']),
"wuttatest": MagicMock(report_modules=["wuttjamaican.reports"]),
}
with patch.object(self.app, 'providers', new=providers):
with patch.object(self.app, "providers", new=providers):
handler = self.make_handler()
modules = handler.get_report_modules()
self.assertEqual(len(modules), 1)
@ -51,9 +51,9 @@ class TestReportHandler(ConfigTestCase):
# provider may specify modules as string
providers = {
'wuttatest': MagicMock(report_modules='wuttjamaican.reports'),
"wuttatest": MagicMock(report_modules="wuttjamaican.reports"),
}
with patch.object(self.app, 'providers', new=providers):
with patch.object(self.app, "providers", new=providers):
handler = self.make_handler()
modules = handler.get_report_modules()
self.assertEqual(len(modules), 1)
@ -62,54 +62,54 @@ class TestReportHandler(ConfigTestCase):
def test_get_reports(self):
# no providers, no reports
with patch.object(self.app, 'providers', new={}):
with patch.object(self.app, "providers", new={}):
handler = self.make_handler()
self.assertEqual(handler.get_reports(), {})
# provider may define reports (via modules)
providers = {
'wuttatest': MagicMock(report_modules=['tests.test_reports']),
"wuttatest": MagicMock(report_modules=["tests.test_reports"]),
}
with patch.object(self.app, 'providers', new=providers):
with patch.object(self.app, "providers", new=providers):
handler = self.make_handler()
reports = handler.get_reports()
self.assertEqual(len(reports), 1)
self.assertIn('mock_foo', reports)
self.assertIn("mock_foo", reports)
def test_get_report(self):
providers = {
'wuttatest': MagicMock(report_modules=['tests.test_reports']),
"wuttatest": MagicMock(report_modules=["tests.test_reports"]),
}
with patch.object(self.app, 'providers', new=providers):
with patch.object(self.app, "providers", new=providers):
handler = self.make_handler()
# as instance
report = handler.get_report('mock_foo')
report = handler.get_report("mock_foo")
self.assertIsInstance(report, mod.Report)
self.assertIsInstance(report, MockFooReport)
# as class
report = handler.get_report('mock_foo', instance=False)
report = handler.get_report("mock_foo", instance=False)
self.assertTrue(issubclass(report, mod.Report))
self.assertIs(report, MockFooReport)
# not found
report = handler.get_report('unknown')
report = handler.get_report("unknown")
self.assertIsNone(report)
def test_make_report_data(self):
providers = {
'wuttatest': MagicMock(report_modules=['tests.test_reports']),
"wuttatest": MagicMock(report_modules=["tests.test_reports"]),
}
with patch.object(self.app, 'providers', new=providers):
with patch.object(self.app, "providers", new=providers):
handler = self.make_handler()
report = handler.get_report('mock_foo')
report = handler.get_report("mock_foo")
data = handler.make_report_data(report)
self.assertEqual(len(data), 2)
self.assertIn('output_title', data)
self.assertEqual(data['output_title'], "MOCK Report")
self.assertIn('data', data)
self.assertEqual(data['data'], [{'foo': 'bar'}])
self.assertIn("output_title", data)
self.assertEqual(data["output_title"], "MOCK Report")
self.assertIn("data", data)
self.assertEqual(data["data"], [{"foo": "bar"}])