Open harperreed opened 1 month ago
To address your request for adding a GitHub Action for running Python tests, we'll need to create two new files and update an existing one. Let's go through each task:
Let's create a new file named .github/workflows/python-tests.yml
to set up the GitHub Actions workflow:
.github/workflows/python-tests.yml
---
+++
@@ -1 +1,28 @@
+name: Python Tests
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ python-version: [3.6, 3.7, 3.8, 3.9]
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install -r requirements.txt
+ - name: Run tests
+ run: |
+ python -m unittest discover tests
Now, let's create a new test file tests/test_emfit_api.py
with a basic test case:
tests/test_emfit_api.py
---
+++
@@ -1 +1,16 @@
+import unittest
+from emfit.api import EmfitAPI
+class TestEmfitAPI(unittest.TestCase):
+ def test_emfit_api_instance(self):
+ api = EmfitAPI()
+ self.assertIsInstance(api, EmfitAPI)
+ self.assertEqual(api.base_url, "https://qs-api.emfit.com/api/v1")
+
+ def test_emfit_api_with_token(self):
+ token = "test_token"
+ api = EmfitAPI(token=token)
+ self.assertEqual(api.token, token)
+
+if __name__ == '__main__':
+ unittest.main()
Let's update the README.md file to include a badge for the GitHub Actions workflow status:
README.md
---
+++
@@ -1,4 +1,6 @@
# EmfitAPI Python Wrapper
+
+![Python Tests](https://github.com/harperreed/emfitapi-python/workflows/Python%20Tests/badge.svg)
## Overview
These changes will add a GitHub Action for running Python tests to your project. Here's a summary of what we've done:
Created a new GitHub Actions workflow file (.github/workflows/python-tests.yml
) that:
Added a simple test file (tests/test_emfit_api.py
) with basic test cases:
EmfitAPI
classEmfitAPI
instance is created correctlyUpdated the README.md
file to include a badge for the GitHub Actions workflow status.
To make these changes effective:
You can now see the test results and the status badge on your GitHub repository page. The badge will show the current status of your tests, providing quick visibility into the health of your project.
Continue the conversation with Sweep here: https://app.sweep.dev/c/584537ab-8072-4a59-87c7-44f53c941e93.
:book: For more information on how to use Sweep, please read our documentation.
Add GitHub Action for Python Tests
Description:
Create a GitHub Actions workflow to automatically run Python tests for the EmfitAPI Python Wrapper project.
Tasks:
.github/workflows/python-tests.yml
Test:
tests/test_emfit_api.py
with a basic test caseEmfitAPI
classEmfitAPI
instance is created correctlyAdditional tasks:
README.md
to include a badge for the GitHub Actions workflow status