Skip to content

Commit

Permalink
allow to select log-level; add ci & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vladkens committed Apr 30, 2023
1 parent 01d59b5 commit 0c1377d
Show file tree
Hide file tree
Showing 26 changed files with 33,660 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/mocked-data/* binary merge
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @vladkens
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: vladkens
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: ci

on: [push]

env:
PIP_ROOT_USER_ACTION: ignore

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install --quiet -r requirements.txt
pip install --quiet -r requirements-dev.txt
- name: lint
run: make lint

- name: test
run: make test
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
all:
@echo "hi"

lint:
ruff check .

lint-fix:
ruff check --fix .

test:
pytest --cov=twapi tests/

act:
act --container-architecture linux/amd64
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ line-length = 99

[tool.ruff]
line-length = 99

[tool.pytest.ini_options]
pythonpath = ["."]
asyncio_mode = "auto"
16 changes: 7 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@ Twitter GraphQL and Search API implementation with [SNScrape](https://github.com

```python
import asyncio
from twapi.account import Account
from twapi.accounts_pool import AccountsPool
from twapi.api import API
from twapi.utils import gather
from twapi import AccountsPool, API, gather
from twapi.logger import set_log_level

async def main():
acc1 = Account("user1", "pass1", "[email protected]", "email_pass1")
acc2 = Account("user2", "pass2", "[email protected]", "email_pass2")

pool = AccountsPool()
pool.add_account(acc1)
pool.add_account(acc2)
pool.add_account("user1", "pass1", "[email protected]", "email_pass1")
pool.add_account("user2", "pass2", "[email protected]", "email_pass2")

# login all accounts if required (not account file found)
# session file will be saved to `accounts/{username}.json`
Expand Down Expand Up @@ -50,6 +45,9 @@ async def main():
async for rep in api.search_raw("elon musk"):
print(rep.status_code, rep.json()) # rep is `httpx.Response` object

# change log level, default info
set_log_level("DEBUG")

if __name__ == "__main__":
asyncio.run(main())
```
4 changes: 4 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ruff==0.0.263
pytest==7.3.1
pytest-asyncio==0.21.0
pytest-cov==4.0.0
Loading

0 comments on commit 0c1377d

Please sign in to comment.