Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stub GrabCAD Media tests #5831

Open
ZachOrr opened this issue Mar 21, 2024 · 0 comments
Open

Stub GrabCAD Media tests #5831

ZachOrr opened this issue Mar 21, 2024 · 0 comments

Comments

@ZachOrr
Copy link
Member

ZachOrr commented Mar 21, 2024

https://github.com/the-blue-alliance/the-blue-alliance/actions/runs/8370703916/job/22918506267

The following tests are flaky on CI due to loading URLs from an API

src/backend/web/handlers/suggestions/tests/suggest_designs_review_controller_test.py::test_accept_suggestion
src/backend/web/handlers/suggestions/tests/suggest_designs_review_controller_test.py::test_reject_suggestion
src/backend/web/handlers/suggestions/tests/suggest_designs_review_controller_test.py::test_fast_path_accept
src/backend/web/handlers/suggestions/tests/suggest_designs_review_controller_test.py::test_fast_path_reject
src/backend/web/handlers/suggestions/tests/suggest_designs_review_controller_test.py::test_fast_path_already_reviewed

Here's output from one of the tests

____________________________ test_accept_suggestion ____________________________

login_user_with_permission = <Mock spec='User' id='140012527716112'>
ndb_stub = <google.appengine.api.datastore_file_stub.DatastoreFileStub object at 0x7f571d243d10>
web_client = <FlaskClient <Flask 'backend.web.main'>>
taskqueue_stub = <google.appengine.api.taskqueue.taskqueue_stub.TaskQueueServiceStub object at 0x7f571d20cd10>

    def test_accept_suggestion(
        login_user_with_permission,
        ndb_stub,
        web_client: Client,
        taskqueue_stub,
    ) -> None:
>       suggestion_id = createSuggestion(login_user_with_permission)

src/backend/web/handlers/suggestions/tests/suggest_designs_review_controller_test.py:92: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/backend/web/handlers/suggestions/tests/suggest_designs_review_controller_test.py:58: in createSuggestion
    status = SuggestionCreator.createTeamMediaSuggestion(
src/backend/common/suggestions/suggestion_creator.py:55: in createTeamMediaSuggestion
    media_dict = MediaParser.partial_media_dict_from_url(media_url)
src/backend/common/suggestions/media_parser.py:107: in partial_media_dict_from_url
    return cls._partial_media_dict_from_grabcad(url)
src/backend/common/suggestions/media_parser.py:267: in _partial_media_dict_from_grabcad
    grabcad_data = json.loads(urlfetch_result.content)
/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/json/__init__.py:346: in loads
    return _default_decoder.decode(s)
/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/json/decoder.py:337: in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <json.decoder.JSONDecoder object at 0x7f575637e5a0>
s = '<?xml version="1.0" encoding="UTF-8"?>\n<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>YF...79HPX</RequestId><HostId>fcTxJzU1vR3UUzif7pOixSYvtKZ1NxUv0tG4ofBUKhN4Z1OgAAQlc8eXb5V6pqy8z2/jyAHkfnA=</HostId></Error>'
idx = 0

    def raw_decode(self, s, idx=0):
        """Decode a JSON document from ``s`` (a ``str`` beginning with
        a JSON document) and return a 2-tuple of the Python
        representation and the index in ``s`` where the document ended.
    
        This can be used to decode a JSON document from a string that may
        have extraneous data at the end.
    
        """
        try:
            obj, end = self.scan_once(s, idx)
        except StopIteration as err:
>           raise JSONDecodeError("Expecting value", s, err.value) from None
E           json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/json/decoder.py:355: JSONDecodeError
------------------------------ Captured log call -------------------------------
WARNING  root:media_parser.py:265 Unable to retreive url: https://grabcad.com/community/api/v1/models/2016-148-robowranglers-1

We should stub the response for these GrabCAD urls so we're not hitting an API upstream in our tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant