Example #1
0
 def test_destroy_no_children(self, fx_deployments, monkeypatch,
                              runway_context):
     """Test destroy with no child modules."""
     mock_async = MagicMock()
     monkeypatch.setattr(Module, "_Module__async", mock_async)
     mock_sync = MagicMock()
     monkeypatch.setattr(Module, "_Module__sync", mock_sync)
     mock_run = MagicMock()
     monkeypatch.setattr(Module, "run", mock_run)
     mod = Module(
         context=runway_context,
         definition=fx_deployments.load("min_required").modules[0],
     )
     assert mod.destroy()
     mock_run.assert_called_once_with("destroy")
     mock_async.assert_not_called()
     mock_sync.assert_not_called()
Example #2
0
 def test_destroy_no_children(
     self,
     fx_deployments: YamlLoaderDeployment,
     mocker: MockerFixture,
     runway_context: MockRunwayContext,
 ) -> None:
     """Test destroy with no child modules."""
     mock_async = mocker.patch.object(Module, "_Module__async")
     mock_sync = mocker.patch.object(Module, "_Module__sync")
     mock_run = mocker.patch.object(Module, "run")
     mod = Module(
         context=runway_context,
         definition=fx_deployments.load("min_required").modules[0],
     )
     assert mod.destroy()
     mock_run.assert_called_once_with("destroy")
     mock_async.assert_not_called()
     mock_sync.assert_not_called()
Example #3
0
    def test_destroy(self, async_used, fx_deployments, monkeypatch,
                     runway_context):
        """Test destroy."""
        mock_async = MagicMock()
        monkeypatch.setattr(Module, "_Module__async", mock_async)
        mock_sync = MagicMock()
        monkeypatch.setattr(Module, "_Module__sync", mock_sync)
        monkeypatch.setattr(Module, "use_async", async_used)
        mod = Module(
            context=runway_context,
            definition=fx_deployments.load(
                "simple_parallel_module").modules[0],
        )
        assert mod.destroy()

        if async_used:
            mock_async.assert_called_once_with("destroy")
            mock_sync.assert_not_called()
        else:
            mock_async.assert_not_called()
            mock_sync.assert_called_once_with("destroy")
Example #4
0
    def test_destroy(
        self,
        async_used: bool,
        fx_deployments: YamlLoaderDeployment,
        mocker: MockerFixture,
        runway_context: MockRunwayContext,
    ) -> None:
        """Test destroy."""
        mock_async = mocker.patch.object(Module, "_Module__async")
        mock_sync = mocker.patch.object(Module, "_Module__sync")
        mocker.patch.object(Module, "use_async", async_used)
        mod = Module(
            context=runway_context,
            definition=fx_deployments.load(
                "simple_parallel_module").modules[0],
        )
        assert mod.destroy()

        if async_used:
            mock_async.assert_called_once_with("destroy")
            mock_sync.assert_not_called()
        else:
            mock_async.assert_not_called()
            mock_sync.assert_called_once_with("destroy")