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

Fix union use in utils.py & add tox GitHub workflow #35

Merged
merged 3 commits into from
Jul 9, 2024
Merged
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
35 changes: 35 additions & 0 deletions .github/workflows/tox.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: tox

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
pytest:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox

- name: Run Tests
run: tox run -m ${{ matrix.python-version }}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,11 @@ poetry install

# Run the tool
poetry run edgar-tool --help

# Run unit tests using your Poetry environment's Python interpreter
poetry run pytest

# Run unit tests with tox
poetry run tox -- run-parallel
```
</details>
2 changes: 2 additions & 0 deletions edgar_tool/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import re
from datetime import date
from typing import Any, Iterator, Dict, List, Union, Optional
Expand Down
149 changes: 140 additions & 9 deletions poetry.lock

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

10 changes: 7 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "edgar-tool"
version = "1.3.2"
version = "1.3.3"
description = "Search and retrieve corporate and financial data from the United States Securities and Exchange Commission (SEC)."
authors = ["Bellingcat"]
license = "GNU General Public License v3 (GPLv3)"
Expand All @@ -12,6 +12,10 @@ classifiers = [
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Office/Business :: Financial",
]
keywords=["scraper", "edgar", "finance", "sec"]
Expand All @@ -32,8 +36,8 @@ xmltodict = "^0.13"

[tool.poetry.group.dev.dependencies]
black = "^24.2.0"

tox = "^4.16.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
build-backend = "poetry.core.masonry.api"
29 changes: 29 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import subprocess


def test_cli_should_return_help_string_when_passed_no_args():
"""Tests that running edgar-tool without any arguments returns the CLI's help string and 0 exit code."""
# GIVEN
expected = """
NAME
edgar-tool

SYNOPSIS
edgar-tool COMMAND

COMMANDS
COMMAND is one of the following:

rss
Fetch the latest RSS feed data for the given company tickers and save it to either a CSV, JSON, or JSONLines file.

text_search
Perform a custom text search on the SEC EDGAR website and save the results to either a CSV, JSON, or JSONLines file.
"""

# WHEN
result = subprocess.run(["edgar-tool"], capture_output=True, text=True)

# THEN
assert result.returncode == 0
assert result.stdout.strip() == expected.strip()
14 changes: 14 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tox]
envlist = py39, py310, py311, py312
labels =
; Used to map GitHub workflow python version to tox env
3.9 = py39
3.10 = py310
3.11 = py311
3.12 = py312

[testenv]
deps =
pytest>=8
commands =
pytest tests/ --import-mode=importlib
Loading