-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #689 from hackforla/684-BACK-PostmanIntegration
postman integration
- Loading branch information
Showing
20 changed files
with
1,465 additions
and
107 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 |
---|---|---|
@@ -1,26 +1,34 @@ | ||
name: Dev_CI_Backend | ||
on: [pull_request] | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'server/**' | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: server | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.7] | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
sudo apt install libpq-dev python3-dev | ||
python -m pip install --upgrade pip | ||
pip install -r server/api/requirements.txt | ||
cp server/.env.example server/api/.env | ||
- name: Lint with flake8 | ||
run: flake8 server | ||
# disabled until we have a test DB to connect to | ||
# - name: Test with pytest | ||
# run: pytest server | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install and Run Api | ||
run: | | ||
cp .env.example .env | ||
echo SOCRATA_TOKEN=${{ secrets.SOCRATA_TOKEN }} >> .env | ||
docker-compose up --no-start api | ||
docker-compose run api python bin/db_seed.py --years 2020 --rows 500 --reset | ||
docker-compose up -d api | ||
- name: Linting | ||
run: docker-compose run api flake8 | ||
|
||
- name: Unit Tests | ||
run: docker-compose run api pytest | ||
|
||
- name: Postman Tests | ||
run: chmod +x postman/test.sh && postman/test.sh |
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
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
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
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
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
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
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,5 @@ | ||
import app | ||
|
||
|
||
def test_app(): | ||
assert hasattr(app, 'start') |
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
import db | ||
from datetime import datetime | ||
|
||
|
||
class TestDB: | ||
def test_version(self): | ||
version = db.version() | ||
assert isinstance(version, int) | ||
|
||
def test_last_updated(self): | ||
last_updated = db.info.last_updated() | ||
assert isinstance(last_updated, datetime) | ||
|
||
def test_rows(self): | ||
rows = db.info.rows() | ||
assert isinstance(rows, dict) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,44 @@ | ||
## Setup | ||
|
||
### 1. Install and run Postman | ||
|
||
Download it [here](https://www.postman.com/downloads/) and start it up. | ||
|
||
### 2. Create a 311 workspace (optional) | ||
|
||
If you create a workspace, all of your 311 stuff will be grouped together, so it won't get jumbled up with anything else you're doing in Postman. | ||
|
||
To create one, select "create new" from dropdown menu in the middle of the nav bar (top of the window). Give it a name, select "Personal" type (instead of "Team"), and hit "Create Workspace". | ||
|
||
### 3. Import this folder | ||
|
||
Click the Import button at the top left, select "Folder" from the tabs, and then select this folder (`/server/postman`) from the finder. The import will add two collections to Postman: | ||
- **311-all**: a collection containing all of the endpoints that the api currently supports, with prepopulated params for each api call. | ||
- **311-CI**: a collection containing all of the tests we run during continuous integration. These include tests for bad input -- e.g., a missing required param should return 400, an unsupported endpoint should return a 404. | ||
|
||
The import will also add two environments: | ||
- **311-local**: all api calls go to your local server (which should be running) | ||
- **311-prod**: api calls go to the production server | ||
|
||
### 4. Activate the `311-local` environment. | ||
|
||
Just select it from the dropdown at the top right of the window. | ||
|
||
## Usage | ||
|
||
### Run a single api call | ||
|
||
Open the `311-all` collection on the left, and click one of the endpoints. Then click the blue "Send" button next to the url bar. This will send a request to the endpoint and show you the result. If you click around underneath the url bar, you'll find the body of the request (if it's a POST), and in the section below that, the body of the response. | ||
|
||
### Run an entire collection | ||
|
||
Click "Runner" at the top left to open the collection runner. Then select one of the two collections, select the `311-local` environment, and hit the blue button. Postman will make an api call to your local server for each item in the collection, and print a summary of the results. | ||
|
||
Note that the `311-CI` collection contains all of the tests we run whenever you submit a pull request to `dev`. So if you want to help make sure your PR gets approved, run these tests before submitting. | ||
|
||
### Run CI tests from the command line | ||
|
||
As an alternative to running the CI tests in Postman, you can run them from the command line. Run this command from the `/server` directory: | ||
``` | ||
chmod +x postman/test.sh && postman/test.sh | ||
``` |
Oops, something went wrong.