def test_from_config_file_no_arg(mocker, cfgdict): cdmock = mocker.patch('check_wheel_contents.config.ConfigDict', autospec=True) cdmock.find_default.return_value = cfgdict if cfgdict is None: expected = Configuration() else: expected = Configuration.from_config_dict(cfgdict) cfg = Configuration.from_config_file() assert cfg == expected assert cdmock.method_calls == [mocker.call.find_default()]
def test_from_config_file(mocker, cfgdict): cdmock = mocker.patch('check_wheel_contents.config.ConfigDict', autospec=True) cdmock.from_file.return_value = cfgdict if cfgdict is None: expected = Configuration() else: expected = Configuration.from_config_dict(cfgdict) path = '/foo/bar/quux' cfg = Configuration.from_config_file(path) assert cfg == expected assert cdmock.method_calls == [mocker.call.from_file(Path(path))]
def test_from_config_file_no_arg(mocker, cfg): """ Test that calling ``Configuration.from_config_file()`` with no arguments delegates to ``Configuration.find_default()`` and that `None` return values are converted to a default-valued `Configuration` """ mock = mocker.patch.object(Configuration, 'find_default', return_value=cfg) if cfg is None: expected = Configuration() else: expected = cfg assert Configuration.from_config_file() == expected mock.assert_called_once_with()
def test_from_config_file(mocker, cfg): """ Test that calling ``Configuration.from_config_file(path)`` delegates to ``Configuration.from_file()`` and that `None` return values are converted to a default-valued `Configuration` """ mock = mocker.patch.object(Configuration, 'from_file', return_value=cfg) if cfg is None: expected = Configuration() else: expected = cfg path = '/foo/bar/quux' assert Configuration.from_config_file(path) == expected mock.assert_called_once_with(Path(path))