Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests and Updates #41

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application

on:
push:
#branches: [ "main" ]
#pull_request:
#branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

# PYTHON

- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"

# INSTALL PACKAGES

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies with Poetry
run: |
poetry --version
poetry install --with dev

# LINTING

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

# TESTS

- name: Test with pytest
env:
# set environment variables using repo secrets
TRUTHSOCIAL_USERNAME: ${{ secrets.TRUTHSOCIAL_USERNAME }}
TRUTHSOCIAL_PASSWORD: ${{ secrets.TRUTHSOCIAL_PASSWORD }}
Copy link
Contributor Author

@s2t2 s2t2 Oct 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These values need to be set on the upstream repo, using the repository secrets menu in the settings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the login isn't really needed: #32

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like that's maybe a change from when we first built the tool. Pretty sure it used to all be authwalled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing the username and password allows us to test auth-walled functionality.

We can use a new test account if concerned about security.

run: |
poetry run pytest
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ truthbrush --help # will use your local copy of truthbrush
If you prefer not to install Poetry in your root environment, you can also use Conda:

```sh
conda create -n truthbrush-env python=3.9
conda create -n truthbrush-env python=3.10
conda activate truthbrush-env

conda install -c conda-forge poetry
Expand All @@ -157,6 +157,9 @@ pytest

# optionally run tests with verbose logging outputs:
pytest --log-cli-level=DEBUG -s

# optionally run tests with suppressed warnings:
pytest --disable-pytest-warnings
```

Please format your code with `black`:
Expand All @@ -165,6 +168,11 @@ Please format your code with `black`:
black .
```

### Continuous Integration

The Continuous Integration build on GitHub Actions is controlled via the "python-app.yml" workflow file. To make the build pass, the environment variables `TRUTHSOCIAL_USERNAME` and `TRUTHSOCIAL_PASSWORD` must be set as GitHub repository secrets.


## Wishlist

Support for the following capabilities is planned:
Expand Down
74 changes: 37 additions & 37 deletions poetry.lock

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

34 changes: 34 additions & 0 deletions test/api/groups_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@


#def test_group_search(client):
#
# group_name = "Make America Great Again"
#
# results = list(client.search(searchtype="groups", query=group_name))
#
# # are these different pages?
# # should we return as a single list?
# assert len(results) == 4 # why four pages?
# # why do these have 20 (80 total) if the default limit is 40?
# assert len(results[0]["groups"]) == 20
# assert len(results[1]["groups"]) == 20
# assert len(results[2]["groups"]) == 20
# assert len(results[3]["groups"]) == 20
#
# assert results[0]["groups"][0]["display_name"] == group_name
#


def test_group_search_simplified(client):
group_name = "Make America Great Again"

groups = client.search_simpler(resource_type="groups", query=group_name)
matching_groups = [group for group in groups if group["display_name"] == group_name]
assert len(matching_groups) == 1


def test_group_posts(client):
group_id = "110228354005031735" # "Make America Great Again"

timeline = client.group_posts(group_id)
assert len(timeline) == 20
Loading