Esempio n. 1
0
def test_get_valid_ro_apikey():
    with patch.object(ConfigParser.ConfigParser,
                      'get',
                      return_value=ID_WITH_VALID_LENGTH):
        ro_api_key = api_utils.get_ro_apikey()

        assert ro_api_key == ID_WITH_VALID_LENGTH
Esempio n. 2
0
def test_get_invalid_ro_apikey(capsys):
    with patch.object(ConfigParser.ConfigParser, 'get',
                      return_value=ID_WITH_INVALID_LENGTH):
        with pytest.raises(SystemExit):
            ro_api_key = api_utils.get_ro_apikey()
            out, err = capsys.readouterr()

            assert ro_api_key is None
            assert ID_WITH_INVALID_LENGTH in out
            assert 'is not of correct length' in out
Esempio n. 3
0
def test_get_invalid_ro_apikey(capsys):
    with patch.object(ConfigParser.ConfigParser,
                      'get',
                      return_value=ID_WITH_INVALID_LENGTH):
        with pytest.raises(SystemExit):
            ro_api_key = api_utils.get_ro_apikey()
            out, err = capsys.readouterr()

            assert ro_api_key is None
            assert ID_WITH_INVALID_LENGTH in out
            assert 'is not of correct length' in out
Esempio n. 4
0
def test_get_rw_apikey_if_ro_apikey_not_present(mock_get):
    read_write_api_key = ID_WITH_VALID_LENGTH
    api_key = api_utils.get_ro_apikey()
    assert api_key == read_write_api_key
Esempio n. 5
0
def test_get_rw_apikey_if_ro_apikey_not_present(mock_get):
    read_write_api_key = ID_WITH_VALID_LENGTH
    api_key = api_utils.get_ro_apikey()
    assert api_key == read_write_api_key
Esempio n. 6
0
def test_get_valid_ro_apikey():
    with patch.object(ConfigParser.ConfigParser, 'get', return_value=ID_WITH_VALID_LENGTH):
        ro_api_key = api_utils.get_ro_apikey()

        assert ro_api_key == ID_WITH_VALID_LENGTH