Skip to content

Commit 84eec7f

Browse files
committed
feat(integration_tests): add integration tests for BitBucket
1 parent 124ec74 commit 84eec7f

File tree

2 files changed

+57
-9
lines changed

2 files changed

+57
-9
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ jobs:
7575
- name: Run Integration Tests
7676
env:
7777
GH_INTEGRATION_TESTS_TOKEN: ${{ secrets.GH_INTEGRATION_TESTS_TOKEN }}
78+
BITBUCKET_INTEGRATION_TESTS_TOKEN: ${{ secrets.BITBUCKET_INTEGRATION_TESTS_TOKEN }}
79+
BITBUCKET_INTEGRATION_TESTS_URL: ${{ secrets.BITBUCKET_INTEGRATION_TESTS_URL }}
7880
run: |
7981
python3 -m pip install pytest
8082
pytest tests

tests/integration_test.py

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,32 @@
22
import json
33
import subprocess
44
import pytest
5+
import sys
56

67
from typing import Set, Optional, List
78

89
GH_INTEGRATION_TESTS_TOKEN = os.environ["GH_INTEGRATION_TESTS_TOKEN"]
10+
BITBUCKET_INTEGRATION_TESTS_TOKEN = os.environ["BITBUCKET_INTEGRATION_TESTS_TOKEN"]
11+
BITBUCKET_INTEGRATION_TESTS_URL = os.environ["BITBUCKET_INTEGRATION_TESTS_URL"]
912

10-
def run_src_fingerprint(provider: str, args: Optional[List[str]] = []):
11-
subprocess.run(
13+
def run_src_fingerprint(provider: str, token: str, args: Optional[List[str]] = []):
14+
return subprocess.run(
1215
[
1316
"./src-fingerprint",
17+
"-v",
1418
"collect",
1519
"-p",
1620
provider,
1721
"--token",
18-
GH_INTEGRATION_TESTS_TOKEN,
22+
token,
1923
"-f",
2024
"jsonl",
2125
"-o",
2226
"fingerprints.jsonl"
2327
] + args,
24-
check=True
28+
check=True,
29+
stdout=subprocess.PIPE,
30+
stderr=subprocess.STDOUT,
2531
)
2632

2733
def load_jsonl(jsonl_path):
@@ -34,7 +40,7 @@ def get_output_repos(output_path) -> Set[str]:
3440

3541

3642
def test_local_repository():
37-
run_src_fingerprint(provider="repository", args=["--object", "../src-fingerprint"])
43+
run_src_fingerprint(provider="repository", token=GH_INTEGRATION_TESTS_TOKEN, args=["--object", "../src-fingerprint"])
3844
repos = get_output_repos("fingerprints.jsonl")
3945
os.remove("fingerprints.jsonl")
4046
assert len(repos) == 1
@@ -118,8 +124,8 @@ def test_local_repository():
118124
)
119125
]
120126
)
121-
def test_src_fingerprint_no_object_specified(title, cmd_args, expected_output_repos):
122-
run_src_fingerprint(provider="github", args=cmd_args)
127+
def test_src_fingerprint_github_no_object_specified(title, cmd_args, expected_output_repos):
128+
run_src_fingerprint(provider="github", token=GH_INTEGRATION_TESTS_TOKEN, args=cmd_args)
123129
output_repos = get_output_repos("fingerprints.jsonl")
124130
os.remove("fingerprints.jsonl")
125131
assert output_repos == expected_output_repos
@@ -179,8 +185,48 @@ def test_src_fingerprint_no_object_specified(title, cmd_args, expected_output_re
179185
)
180186
]
181187
)
182-
def test_src_fingerprint_on_org(title, cmd_args, expected_output_repos):
183-
run_src_fingerprint(provider="github", args=["--object", "gg-src-fingerprint-org"]+cmd_args)
188+
def test_src_fingerprint_github_on_org(title, cmd_args, expected_output_repos):
189+
run_src_fingerprint(provider="github", token=GH_INTEGRATION_TESTS_TOKEN, args=["--object", "gg-src-fingerprint-org"]+cmd_args)
190+
output_repos = get_output_repos("fingerprints.jsonl")
191+
os.remove("fingerprints.jsonl")
192+
assert output_repos == expected_output_repos
193+
194+
195+
@pytest.mark.parametrize(
196+
"title, cmd_args, number_of_expected_output_repos", [
197+
(
198+
"Get all repos accesible to integration tests token",
199+
["--limit", "10"],
200+
10
201+
),
202+
]
203+
)
204+
def test_src_fingerprint_bitbucket_no_object_specified(title, cmd_args, number_of_expected_output_repos):
205+
output = run_src_fingerprint(
206+
provider="bitbucket",
207+
token = BITBUCKET_INTEGRATION_TESTS_TOKEN,
208+
args=cmd_args+["--provider-url", BITBUCKET_INTEGRATION_TESTS_URL]
209+
)
210+
output_repos = get_output_repos("fingerprints.jsonl")
211+
os.remove("fingerprints.jsonl")
212+
assert len(output_repos) == number_of_expected_output_repos
213+
214+
215+
@pytest.mark.parametrize(
216+
"title, cmd_args, expected_output_repos", [
217+
(
218+
"Get all repos accesible to integration tests token for project 'src fingerprint'",
219+
["--limit", "10","--object", "src fingerprint"],
220+
{"src fingerprint test", "main-test-repo"}
221+
),
222+
]
223+
)
224+
def test_src_fingerprint_bitbucket_object_specified(title, cmd_args, expected_output_repos):
225+
output = run_src_fingerprint(
226+
provider="bitbucket",
227+
token = BITBUCKET_INTEGRATION_TESTS_TOKEN,
228+
args=cmd_args+["--provider-url", BITBUCKET_INTEGRATION_TESTS_URL]
229+
)
184230
output_repos = get_output_repos("fingerprints.jsonl")
185231
os.remove("fingerprints.jsonl")
186232
assert output_repos == expected_output_repos

0 commit comments

Comments
 (0)