def test_get_valid_adapters():
    """
    Test to verify that the keys in the internal factory is the same set as
    the resutls from get_valid_adapters()
    """
    saf = ScriptAdapterFactory
    assert (saf.factories.keys() == ScriptAdapterFactory.get_valid_adapters())
def test_local_adapter_in_factory():
    """
    Testing to makes sure that the LocalScriptAdapter has been registered
    correctly in the ScriptAdapterFactory.
    :return:
    """
    saf = ScriptAdapterFactory
    assert(saf.factories[LocalScriptAdapter.key] == LocalScriptAdapter)
    assert(LocalScriptAdapter.key in ScriptAdapterFactory.get_valid_adapters())
    assert(ScriptAdapterFactory.get_adapter(LocalScriptAdapter.key) ==
           LocalScriptAdapter)
示例#3
0
def test_flux_adapter_in_factory():
    """
    Testing to makes sure that the FluxScriptAdapter has been registered
    correctly in the ScriptAdapterFactory.
    :return:
    """
    saf = ScriptAdapterFactory
    # Make sure FluxScriptAdapter is in the facotries object
    assert (saf.factories[FluxScriptAdapter.key] == FluxScriptAdapter)
    # Make sure the FluxScriptAdapter key is in the valid adapters
    assert (FluxScriptAdapter.key in ScriptAdapterFactory.get_valid_adapters())
    # Make sure that get_adapter returns the FluxScriptAdapter when asking
    # for it by key
    assert (ScriptAdapterFactory.get_adapter(
        FluxScriptAdapter.key) == FluxScriptAdapter)
示例#4
0
    def set_adapter(self, adapter):
        """
        Set the adapter used to interface for scheduling tasks.

        :param adapter: Adapter name to be used when launching the graph.
        """
        if not adapter:
            # If we have no adapter specified, assume sequential execution.
            self._adapter = None
            return

        if not isinstance(adapter, dict):
            msg = "Adapter settings must be contained in a dictionary."
            LOGGER.error(msg)
            raise TypeError(msg)

        # Check to see that the adapter type is something the
        if adapter["type"] not in ScriptAdapterFactory.get_valid_adapters():
            msg = "'{}' adapter must be specfied in ScriptAdapterFactory." \
                  .format(adapter)
            LOGGER.error(msg)
            raise TypeError(msg)

        self._adapter = adapter