tokland / shoogle

Use the Google API from the shell
GNU General Public License v3.0
97 stars 13 forks source link

Update tests to avoid using shuttered urlshortener api #11

Closed davesteele closed 3 years ago

davesteele commented 4 years ago

Two new failures have recently cropped up in Debian CI testing.

$ py.test-3 
========================================================================================= test session starts =========================================================================================
platform linux -- Python 3.7.5rc1, pytest-4.6.5, py-1.8.0, pluggy-0.12.0
rootdir: /home/daves/github/shoogle
plugins: requests-mock-1.5.2, asyncio-0.10.0
collected 12 items                                                                                                                                                                                    

tests/test_shoogle.py F..F........                                                                                                                                                              [100%]

============================================================================================== FAILURES ===============================================================================================
________________________________________________________________________ TestShoogle.test_main_execute_with_missing_parameter _________________________________________________________________________

self = <tests.test_shoogle.TestShoogle testMethod=test_main_execute_with_missing_parameter>

    def test_main_execute_with_missing_parameter(self):
        with temporal_file("{}") as request_file:
            e = main(["execute", "urlshortener:v1.url.get", request_file])
>           self.assertEqual(0, e.status)
E           AssertionError: 0 != 1

tests/test_shoogle.py:157: AssertionError
------------------------------------------------------------------------------------------ Captured log call ------------------------------------------------------------------------------------------
ERROR    shoogle-test:shoogle.py:54 GET https://www.googleapis.com/discovery/v1/apis/urlshortener/v1/rest (404)
______________________________________________________________ TestShoogle.test_main_with_exact_method_shows_request_with_minimal_params ______________________________________________________________

self = <tests.test_shoogle.TestShoogle testMethod=test_main_with_exact_method_shows_request_with_minimal_params>

    def test_main_with_exact_method_shows_request_with_minimal_params(self):
        e = main(["show", "urlshortener:v1.url.get"])
        jsons = re.findall(r"^\{$.*?^\}$", e.out, re.MULTILINE | re.DOTALL)

>       self.assertEqual(0, e.status)
E       AssertionError: 0 != 1

tests/test_shoogle.py:147: AssertionError
------------------------------------------------------------------------------------------ Captured log call ------------------------------------------------------------------------------------------
ERROR    shoogle-test:shoogle.py:54 GET https://www.googleapis.com/discovery/v1/apis/urlshortener/v1/rest (404)
========================================================================================== warnings summary ===========================================================================================
/usr/lib/python3/dist-packages/pyasn1/type/constraint.py:130
  /usr/lib/python3/dist-packages/pyasn1/type/constraint.py:130: DeprecationWarning: invalid escape sequence \*
    """

/usr/lib/python3/dist-packages/pyasn1/type/constraint.py:175
  /usr/lib/python3/dist-packages/pyasn1/type/constraint.py:175: DeprecationWarning: invalid escape sequence \*
    """

/usr/lib/python3/dist-packages/pyasn1/type/constraint.py:334
  /usr/lib/python3/dist-packages/pyasn1/type/constraint.py:334: DeprecationWarning: invalid escape sequence \*
    """

/usr/lib/python3/dist-packages/pyasn1/type/constraint.py:494
  /usr/lib/python3/dist-packages/pyasn1/type/constraint.py:494: DeprecationWarning: invalid escape sequence \*
    """

/usr/lib/python3/dist-packages/pyasn1/type/constraint.py:538
  /usr/lib/python3/dist-packages/pyasn1/type/constraint.py:538: DeprecationWarning: invalid escape sequence \*
    """

/usr/lib/python3/dist-packages/pyasn1/type/namedval.py:54
  /usr/lib/python3/dist-packages/pyasn1/type/namedval.py:54: DeprecationWarning: invalid escape sequence \*
    """

/usr/lib/python3/dist-packages/uritemplate/__init__.py:36
  /usr/lib/python3/dist-packages/uritemplate/__init__.py:36: DeprecationWarning: invalid escape sequence \}
    TEMPLATE = re.compile("{([^\}]+)}")

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=========================================================================== 2 failed, 10 passed, 7 warnings in 6.38 seconds ===================================

$ shoogle show urlshortener:v1.url.get [ERROR] GET https://www.googleapis.com/discovery/v1/apis/urlshortener/v1/rest (404)

davesteele commented 4 years ago

The URL returning 404 is the same as in a Google API Discovery Service example at the bottom of https://developers.google.com/discovery/v1/getting_started. This appears to be an upstream problem.

davesteele commented 4 years ago

Ah.

https://www.theverge.com/2018/3/31/17184164/google-alphabet-url-shortening-service-closed