示例#1
0
    def test_get_domains(
        self,
        mocked_load_model_config: MagicMock,
    ) -> None:
        """Test get_domains method."""
        mocked_load_model_config.return_value = {
            "__help__framework_foo": "help for framework_foo",
            "framework_foo": {
                "__help__domain1": "help text for framework_foo/domain1",
                "domain1": {},
                "__help__domain2": "help text for framework_foo/domain2",
                "domain2": {},
                "__help__domain3": "help text for framework_foo/domain3",
                "domain3": {},
            },
            "__help__framework_bar": "help for framework_bar",
            "framework_bar": {
                "__help__domain1": "help text for framework_bar/domain1",
                "domain1": {},
            },
            "__help__framework_baz": "help for framework_baz",
            "framework_baz": {
                "__help__domain1": "help text for framework_baz/domain1",
                "domain1": {},
            },
        }

        expected = [
            {
                "name": "domain1",
                "help": "help text for framework_foo/domain1",
            },
            {
                "name": "domain2",
                "help": "help text for framework_foo/domain2",
            },
            {
                "name": "domain3",
                "help": "help text for framework_foo/domain3",
            },
        ]

        feeder = Feeder(
            data={
                "config": {
                    "framework": "framework_foo",
                },
            },
        )
        actual = feeder.get_domains()

        mocked_load_model_config.assert_called_once()
        self.assertEqual(expected, actual)
示例#2
0
 def test_get_domains_fails_without_framework(self) -> None:
     """Test that get_domains fails when no config given."""
     feeder = Feeder(data={})
     with self.assertRaisesRegex(ClientErrorException, "Framework not set."):
         feeder.get_domains()