Repository: CouncilDataProject/cdp-scrapers (language: python)

Issue:
Add test to pull request workflow
### Feature Description

Add testing to `.github/workflows/test-and-lint.yml`. See [cdp-backend repo](https://github.com/CouncilDataProject/cdp-backend) for relevant example files - `tox.ini`, `setup.cfg`, `setup.py`, etc.

Note, we have `cdp_scrapers/tests/scraper_tests.py`.

### Use Case

Will test pull requests.

### Solution

Run tests after the `Check with Black` step in `test-and-lint.yml`.

### Alternatives

Creating a new GitHub workflow file for testing.



Discussion / hints:
@dphoria @JacksonMaxfield I would like work on this issue.

Fix patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 00000000..f908321c
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,28 @@
+files: cdp_scrapers
+repos:
+    - repo: https://github.com/PyCQA/flake8
+      rev: 3.9.2
+      hooks:
+          - id: flake8
+            additional_dependencies: [flake8-typing-imports, flake8-debugger]
+            args: [--count, --show-source, --statistics, --min-python-version=3.8.0]
+    - repo: https://github.com/myint/autoflake
+      rev: v1.4
+      hooks:
+          - id: autoflake
+            args: ["--in-place", "--remove-all-unused-imports"]
+    - repo: https://github.com/PyCQA/isort
+      rev: 5.9.3
+      hooks:
+          - id: isort
+    - repo: https://github.com/psf/black
+      rev: 22.3.0
+      hooks:
+          - id: black
+    - repo: https://github.com/pre-commit/mirrors-mypy
+      rev: v0.910
+      hooks:
+          - id: mypy
+            additional_dependencies:
+              - "types-pytz"
+              - "types-requests"
diff --git a/setup.py b/setup.py
index 054ec33f..71b2143c 100644
--- a/setup.py
+++ b/setup.py
@@ -12,6 +12,10 @@
     "black>=19.10b0",
     "flake8>=3.8.3",
     "flake8-debugger>=3.2.1",
+    "pytest>=5.4.3",
+    "pytest-cov>=2.9.0",
+    "pytest-raises>=0.11",
+    "tox>=3.15.2",
 ]
 
 dev_requirements = [
diff --git a/tox.ini b/tox.ini
index 08b08cea..c82cb2d6 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,10 +1,19 @@
 [tox]
-skipsdist = True
-envlist = lint
+envlist = py38, py39, py310, lint
+skip_missing_interpreters = true
+toxworkdir={env:TOX_WORK_DIR:.tox}
 
 [testenv:lint]
-deps =
-    .[test]
+skip_install = true
+deps = pre-commit
+commands = pre-commit run --all-files --show-diff-on-failure
+
+[testenv]
+passenv =
+    CI
+setenv =
+    PYTHONPATH = {toxinidir}
+extras =
+    test
 commands =
-    flake8 cdp_scrapers --count --verbose --show-source --statistics
-    black --check cdp_scrapers
+    pytest --basetemp={envtmpdir} --cov-report xml --cov-report html --cov=cdp_scrapers cdp_scrapers/tests/ {posargs}


Test patch:
diff --git a/.github/workflows/test-and-lint.yml b/.github/workflows/test-and-lint.yml
index 45a79ca9..08c16f6e 100644
--- a/.github/workflows/test-and-lint.yml
+++ b/.github/workflows/test-and-lint.yml
@@ -3,6 +3,24 @@ name: Test and Lint
 on: pull_request
 
 jobs:
+  test:
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout@v1
+      - name: Set up Python
+        uses: actions/setup-python@v1
+        with:
+          python-version: 3.9
+      - name: Install Dependencies
+        run: |
+          python -m pip install --upgrade pip
+          pip install .[test]
+      - name: Run tests with Tox
+        run: tox -e py
+      - name: Upload Codecov
+        uses: codecov/codecov-action@v1
+
   lint:
     runs-on: ubuntu-latest
 
diff --git a/cdp_scrapers/tests/scraper_util_tests.py b/cdp_scrapers/tests/test_scraper_utils.py
similarity index 100%
rename from cdp_scrapers/tests/scraper_util_tests.py
rename to cdp_scrapers/tests/test_scraper_utils.py
diff --git a/cdp_scrapers/tests/scraper_tests.py b/cdp_scrapers/tests/test_scrapers.py
similarity index 100%
rename from cdp_scrapers/tests/scraper_tests.py
rename to cdp_scrapers/tests/test_scrapers.py