Skip to content

Commit

Permalink
chore: add test ci (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
chyroc authored Sep 22, 2024
1 parent 19bfbd2 commit e29e6a7
Show file tree
Hide file tree
Showing 5 changed files with 316 additions and 4 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: CI
on:
push:
branches:
- main
pull_request:
merge_group:

jobs:
test:
runs-on: ${{ matrix.os }}
name: test (Python ${{ matrix.python-version }} on ${{ matrix.os-label }})
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: ["ubuntu-latest"]
os-label: ["Ubuntu"]
include:
- {python-version: "3.8", os: "windows-latest", os-label: "Windows"}
- {python-version: "3.8", os: "macos-latest", os-label: "macOS"}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python-version }}"
- name: Install Dependencies
run: |
pip install poetry
poetry install
- name: Run tests
run: poetry run pytest
env:
COZE_TOKEN: ${{ secrets.COZE_TOKEN }}
SPACE_ID_1: ${{ secrets.SPACE_ID_1 }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

test_success:
# this aggregates success state of all jobs listed in `needs`
# this is the only required check to pass CI
name: "Test success"
if: always()
runs-on: ubuntu-latest
needs: [test]
steps:
- name: "Success"
if: needs.test.result == 'success'
run: true
shell: bash
- name: "Failure"
if: needs.test.result != 'success'
run: false
shell: bash

draft:
runs-on: ubuntu-latest
needs: test_success
if: github.ref == 'refs/heads/main'
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions cozepy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from auth import Auth, PersonalAccessToken
from .auth import Auth, PersonalAccessToken

from coze import Coze
from .coze import Coze

from model import TokenPaged, NumberPaged
from .model import TokenPaged, NumberPaged

__all__ = [
'Auth',
Expand Down
228 changes: 227 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ python = "^3.8"
requests = "^2.32.3"
pydantic = "^2.9.2"

[tool.poetry.group.dev.dependencies]
pytest = "^8.3.3"
tox = "^4.20.0"

[build-system]
requires = ["poetry-core"]
Expand Down
19 changes: 19 additions & 0 deletions tests/test_bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
from unittest import TestCase

from cozepy import PersonalAccessToken, Coze


class TestBotClient(TestCase):
def test_list_published_bots_v1(self):
space_id = os.getenv('SPACE_ID_1').strip()
token = os.getenv('COZE_TOKEN').strip()
for i in token:
print('token', i)
auth = PersonalAccessToken(token)
cli = Coze(auth=auth, base_url='https://api.coze.cn')

res = cli.bot.list_published_bots_v1(space_id=space_id, page_size=2)
assert res.total > 1
assert res.has_more
assert len(res.items) > 1

0 comments on commit e29e6a7

Please sign in to comment.