-
-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow to select log-level; add ci & tests
- Loading branch information
Showing
26 changed files
with
33,660 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tests/mocked-data/* binary merge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @vladkens |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: vladkens |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,7 @@ line-length = 99 | |
|
||
[tool.ruff] | ||
line-length = 99 | ||
|
||
[tool.pytest.ini_options] | ||
pythonpath = ["."] | ||
asyncio_mode = "auto" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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` | ||
|
@@ -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()) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.