mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-10-28 09:03:46 +08:00
6d742eb343
Add control trace and platform qualification tools that exercise explicit safety modes and vehicle coverage. Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com> Co-authored-by: Kacper Rączy <gfw.kra@gmail.com> Co-authored-by: YassineYousfi <yyousfi1@binghamton.edu> Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com> Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com> Co-authored-by: prabhaavp <prabhaav@msu.edu>
41 lines
1.8 KiB
Python
41 lines
1.8 KiB
Python
from http import HTTPMethod
|
|
from unittest.mock import Mock
|
|
|
|
import pytest
|
|
|
|
from openpilot.tools.lib.github_utils import GithubUtils
|
|
|
|
|
|
@pytest.mark.parametrize("comments,marker,expected_path", [
|
|
([{"id": 1, "user": {"login": "bot"}, "body": "_model_tici_"},
|
|
{"id": 2, "user": {"login": "bot"}, "body": "_model_chestnut_"}], "_model_chestnut_", "issues/comments/2"),
|
|
([{"id": 1, "user": {"login": "bot"}, "body": "_model_chestnut_"},
|
|
{"id": 2, "user": {"login": "bot"}, "body": "_model_tici_"}], "_model_tici_", "issues/comments/2"),
|
|
([{"id": 1, "user": {"login": "other"}, "body": "_model_tici_"}], "_model_tici_", "issues/42/comments"),
|
|
([{"id": 1, "user": {"login": "bot"}, "body": "old report"}], "", "issues/comments/1"),
|
|
([], "_model_tici_", "issues/42/comments"),
|
|
])
|
|
def test_comment_overwrite_is_scoped_to_author_and_marker(comments, marker, expected_path):
|
|
github = GithubUtils("", "")
|
|
github.get_pr_number = Mock(return_value=42)
|
|
github.api_call = Mock(return_value=Mock(json=Mock(return_value=comments)))
|
|
|
|
github.comment_on_pr("new report", "branch", "bot", True, comment_marker=marker)
|
|
|
|
calls = github.api_call.call_args_list
|
|
assert calls[0].args == ("issues/42/comments",)
|
|
assert calls[1].args == (expected_path,)
|
|
assert calls[1].kwargs["method"] == (HTTPMethod.PATCH if expected_path.startswith("issues/comments/") else HTTPMethod.POST)
|
|
assert calls[1].kwargs["data"] == '{"body": "new report"}'
|
|
assert len(calls) == 2
|
|
|
|
|
|
def test_new_comment_does_not_read_or_replace_existing_comments():
|
|
github = GithubUtils("", "")
|
|
github.get_pr_number = Mock(return_value=42)
|
|
github.api_call = Mock()
|
|
|
|
github.comment_on_pr("new report", "branch", "bot", False, comment_marker="_model_tici_")
|
|
|
|
github.api_call.assert_called_once_with("issues/42/comments", data='{"body": "new report"}', method=HTTPMethod.POST)
|