Skip to content

Commit

Permalink
Pass tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
klieret committed May 24, 2024
1 parent 577adf9 commit 9cf41b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tests/test_run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
from pathlib import Path
import subprocess
from typing import Any, Dict
Expand All @@ -8,6 +9,7 @@
from sweagent.agent.agents import Agent, AgentArguments, AgentHook
from sweagent.agent.models import ModelArguments
from sweagent.environment.swe_env import EnvironmentArguments, SWEEnv
from unittest.mock import Mock

def test_run_cli_help():
args = [
Expand All @@ -23,7 +25,8 @@ def test_run_cli_help():
def open_pr_hook_init_for_sop():
hook = OpenPRHook()
hook._token = ""
hook._env = None
hook._env = Mock()
hook._env._github_token = os.environ.get("GITHUB_TOKEN", "")
hook._data_path = "https://github.com/klieret/swe-agent-test-repo/issues/1"
hook._open_pr = True
hook._skip_if_commits_reference_issue = True
Expand Down
9 changes: 8 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import hashlib
import os
import subprocess
import pytest
from sweagent.environment.utils import InvalidGithubURL, format_trajectory_markdown, _MARKDOWN_TRAJECTORY_EMOJI_MAPPING, get_instances, is_github_repo_url, remove_triple_backticks, parse_gh_repo_url, parse_gh_issue_url, is_github_issue_url, get_associated_commit_urls


_TOKEN = {"token": os.environ.get("GITHUB_TOKEN", "")}

def test_format_trajectory_markdown(test_trajectory):
formatted = format_trajectory_markdown(test_trajectory["trajectory"])
assert formatted.startswith("<details>")
Expand Down Expand Up @@ -92,6 +96,7 @@ def test_get_instance_gh_issue_local_repo(tmp_path):
instance = get_instances(
file_path="https://github.com/klieret/swe-agent-test-repo/issues/1",
repo_path=str(tmp_path / "swe-agent-test-repo"),
**_TOKEN
)[0]
compare_with = {
'repo': str(tmp_path.resolve() / "swe-agent-test-repo"),
Expand Down Expand Up @@ -129,6 +134,7 @@ def test_get_instance_gh_issue_gh_repo(tmp_path):
instance = get_instances(
file_path="https://github.com/klieret/swe-agent-test-repo/issues/1",
repo_path="https://github.com/princeton-nlp/SWE-agent",
**_TOKEN
)[0]
compare_with = {
'repo': "princeton-nlp/SWE-agent",
Expand All @@ -146,6 +152,7 @@ def test_get_instance_text_issue_gh_repo(tmp_path):
instance = get_instances(
file_path="text://this is a test",
repo_path="https://github.com/princeton-nlp/SWE-agent",
**_TOKEN
)[0]
compare_with = {
'repo': "princeton-nlp/SWE-agent",
Expand All @@ -162,4 +169,4 @@ def test_load_instances(test_data_path, caplog):
test_data_sources = test_data_path / "data_sources"
examples = list(test_data_sources.iterdir())
for example in examples:
get_instances(file_path=str(example))
get_instances(file_path=str(example), **_TOKEN)

0 comments on commit 9cf41b4

Please sign in to comment.