def test_get_valid_owner_apikey_id(): with patch.object(ConfigParser.ConfigParser, 'get', return_value=ID_WITH_VALID_LENGTH): owner_api_key_id = api_utils.get_owner_apikey_id() assert owner_api_key_id == ID_WITH_VALID_LENGTH
def test_get_invalid_owner_apikey_id(capsys): with patch.object(ConfigParser.ConfigParser, 'get', return_value=ID_WITH_INVALID_LENGTH): with pytest.raises(SystemExit): api_utils.load_config = Mock() result = api_utils.get_owner_apikey_id() out, err = capsys.readouterr() assert result is None assert ID_WITH_INVALID_LENGTH in out assert 'is not of correct length' in out