Exemplo n.º 1
0
    def test_create_config_port(self) -> None:
        storage = DataStorage(self.test_dir + 'PynPoint_database.hdf5')

        with pytest.raises(ValueError) as error:
            ConfigPort('images', storage)

        assert str(error.value) == 'The tag name of the central configuration should be ' \
                                   '\'config\'.'

        port = ConfigPort('config', None)

        with pytest.warns(UserWarning) as warning:
            check_error = port._check_error_cases()

        assert len(warning) == 1
        assert warning[0].message.args[0] == 'ConfigPort can not load data unless a database is ' \
                                             'connected.'

        assert not check_error

        port = ConfigPort('config', storage)
        assert isinstance(port, ConfigPort)

        with pytest.warns(UserWarning) as warning:
            port._check_error_cases()

        assert len(warning) == 1
        assert warning[0].message.args[0] == 'No data under the tag which is linked by the ' \
                                             'ConfigPort.'
Exemplo n.º 2
0
    def test_create_config_port(self):
        storage = DataStorage(self.test_dir + "PynPoint_database.hdf5")

        with pytest.raises(ValueError) as error:
            ConfigPort("images", storage)

        assert str(
            error.value
        ) == "The tag name of the central configuration should be 'config'."

        port = ConfigPort("config", None)

        with pytest.warns(UserWarning) as warning:
            check_error = port._check_error_cases()

        assert len(warning) == 1
        assert warning[0].message.args[0] == "ConfigPort can not load data unless a database is " \
                                             "connected."

        assert not check_error

        port = ConfigPort("config", storage)
        assert isinstance(port, ConfigPort)

        with pytest.warns(UserWarning) as warning:
            port._check_error_cases()

        assert len(warning) == 1
        assert warning[0].message.args[
            0] == "No data under the tag which is linked by the ConfigPort."