Skip to content

Commit a33bdaa

Browse files
committed
test: add gitcode test
1 parent 8641d9e commit a33bdaa

21 files changed

Lines changed: 526 additions & 250 deletions

File tree

.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GITCODE_BASE_URL=
2+
GITCODE_PERSONAL_OWNER=
3+
GITCODE_PERSONAL_ACCESS_TOKEN=

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ jobs:
2424

2525
- name: Run tests
2626
run: uv run pytest tests --alluredir=allure-results
27+
env:
28+
GITCODE_BASE_URL: ${{ env.GITCODE_BASE_URL }}
29+
GITCODE_PERSONAL_ACCESS_TOKEN: ${{ env.GITCODE_PERSONAL_ACCESS_TOKEN }}
30+
GITCODE_PERSONAL_OWNER: ${{ env.GITCODE_PERSONAL_OWNER }}
2731

2832
- name: Load test report history
2933
uses: actions/checkout@v3
@@ -48,4 +52,3 @@ jobs:
4852
github_token: ${{ secrets.GITHUB_TOKEN }}
4953
publish_branch: gh-pages
5054
publish_dir: allure-history
51-

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ wheels/
1313

1414
# Allure reports
1515
allure-results/
16-
allure-report/
16+
allure-report/
17+
18+
.env.local

.pre-commit-config.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ repos:
99
- id: trailing-whitespace
1010
- id: check-merge-conflict
1111
- repo: https://github.com/astral-sh/uv-pre-commit
12-
rev: 0.7.17
12+
rev: 0.7.19
1313
hooks:
1414
- id: uv-lock
1515
files: ^(uv\.lock|pyproject\.toml|uv\.toml)$
1616
- id: uv-sync
1717
args: [ "--locked" ]
1818
- repo: https://github.com/astral-sh/ruff-pre-commit
19-
rev: v0.12.1
19+
rev: v0.12.2
2020
hooks:
21-
- id: ruff
22-
args: [ --fix ]
23-
- id: ruff-format
24-
args: [ --fix ]
21+
- id: ruff-check
22+
args: [ --fix ]
23+
- id: ruff-format

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
],
1313
"python.testing.unittestEnabled": false,
1414
"python.testing.pytestEnabled": true
15-
}
15+
}

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,9 @@ pytest tests/test_mod.py::TestClass
4949
pytest tests/test_mod.py::TestClass::test_method
5050
pytest -k 'MyClass and not method'
5151
pytest -m slow
52-
```
52+
```
53+
54+
```bash
55+
find . -type f -name "*.Identifier" -exec rm -f {} +
56+
uv run --env-file .env.local pytest tests/test_tag.py -v
57+
```

gitcode/pages/issues.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import json
2+
3+
import allure
4+
import requests
5+
from loguru import logger
6+
from pydantic import BaseModel
7+
8+
9+
class Env(BaseModel):
10+
base_url: str
11+
token: str
12+
13+
14+
class IssuesAPI:
15+
def __init__(self, env: Env) -> None:
16+
self.env = env
17+
18+
@allure.step("get jsonplaceholder posts list")
19+
def get_user_repos(self) -> list[dict]:
20+
url = f"{self.env.base_url}/user/repos"
21+
response = requests.get(url)
22+
assert response.status_code == 200, f"status code is {response.status_code}"
23+
data = response.json()
24+
logger.info(data)
25+
allure.attach(json.dumps(response), allure.attachment_type.JSON)
26+
return data
27+
28+
29+
class PostsLogic: ...
30+
31+
32+
class PostsValidator:
33+
@allure.step("check posts list")
34+
@staticmethod
35+
def check_posts_list(data: list) -> bool:
36+
return isinstance(data, list) and len(data) > 0
File renamed without changes.

0 commit comments

Comments
 (0)