Пример #1
0
    def test_disable_no_config(self, mock_require_checkout: mock.MagicMock) -> None:
        self.mock_args.checkout = "test"
        mock_require_checkout.return_value = (self.mock_eden_instance, None, None)

        test_config = EdenConfigParser()
        self.mock_eden_instance.read_local_config.return_value = test_config

        test_disable = DisableProfileCmd(self.mock_argument_parser)
        test_disable.run(self.mock_args)

        self.mock_eden_instance.read_local_config.assert_called_once()
        self.mock_eden_instance.write_local_config.assert_called_once_with(test_config)
        self.assertEqual(
            test_config.get_section_str_to_any("prefetch-profiles"),
            {"prefetching-enabled": False},
        )
Пример #2
0
    def test_enable_no_config(self,
                              mock_get_eden_instance: mock.MagicMock) -> None:
        mock_get_eden_instance.return_value = self.mock_eden_instance

        test_config = EdenConfigParser()
        self.mock_eden_instance.read_local_config.return_value = test_config

        test_enable = EnableProfileCmd(self.mock_argument_parser)
        test_enable.run(self.mock_args)

        self.mock_eden_instance.read_local_config.assert_called_once()
        self.mock_eden_instance.write_local_config.assert_called_once_with(
            test_config)
        self.assertEqual(
            test_config.get_section_str_to_any("prefetch-profiles"),
            {"prefetching-enabled": True},
        )
Пример #3
0
    def test_enable_existing_config(
            self, mock_get_eden_instance: mock.MagicMock) -> None:
        mock_get_eden_instance.return_value = self.mock_eden_instance

        test_config = EdenConfigParser()
        test_config.read_dict({
            "prefetch-profiles": {
                "prefetching-enabled": False,
            },
            "something-random": {
                "yup": "test",
            },
        })
        self.mock_eden_instance.read_local_config.return_value = test_config

        test_enable = EnableProfileCmd(self.mock_argument_parser)
        test_enable.run(self.mock_args)

        self.mock_eden_instance.read_local_config.assert_called_once()
        self.mock_eden_instance.write_local_config.assert_called_once_with(
            test_config)
        self.assertEqual(
            test_config.get_section_str_to_any("prefetch-profiles"),
            {"prefetching-enabled": True},
        )
        self.assertTrue(test_config.has_section("something-random"))
        self.assertEqual(
            test_config.get_section_str_to_any("something-random"),
            {"yup": "test"})