-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into electionsEndpoints
- Loading branch information
Showing
5 changed files
with
124 additions
and
36 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
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,34 +1,70 @@ | ||
name: Codecov | ||
on: [push] | ||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
release: | ||
types: [ published ] | ||
jobs: | ||
run: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
env: | ||
OS: ${{ matrix.os }} | ||
PYTHON: '3.8' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Setup Python | ||
uses: actions/setup-python@master | ||
with: | ||
python-version: 3.8 | ||
- name: Generate coverage report | ||
run: | | ||
pip install pytest | ||
pip install pytest-cov | ||
pytest --cov=./ --cov-report=xml | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./coverage1.xml,./coverage2.xml | ||
directory: ./coverage/reports/ | ||
flags: unittests | ||
env_vars: OS,PYTHON | ||
name: codecov-umbrella | ||
fail_ci_if_error: true | ||
path_to_write_report: ./coverage/codecov_report.txt | ||
verbose: true | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.9' | ||
architecture: 'x64' | ||
|
||
- name: Get Cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
${{ runner.os }}- | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install wheel | ||
pip install -r requirements.txt | ||
- name: Generate coverage report | ||
run: | | ||
pip install pytest pytest-cov | ||
pip install codecov && codecov -t ${{ secrets.CODECOV_TOKEN }} | ||
python -m pytest --cov=./ && codecov -f .\coverage.xml | ||
env: | ||
# Google Cloud Env | ||
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | ||
GCP_ZONE: ${{ secrets.GCP_ZONE }} | ||
|
||
# Cloud SQL Env | ||
SQL_INST: ${{ secrets.SQL_INST_STAGING }} | ||
DB_READ: ${{ secrets.DB_READ_STAGING }} | ||
DB_USER: ${{ secrets.DB_USER_STAGING }} | ||
DB_PASS: ${{ secrets.DB_PASS_STAGING }} | ||
SQL_INST_PG: ${{ secrets.SQL_INST_PG_STAGING }} | ||
DB_NAME_PG: ${{ secrets.DB_NAME_PG_STAGING }} | ||
DB_USER_PG: ${{ secrets.DB_USER_PG_STAGING }} | ||
DB_PASS_PG: ${{ secrets.DB_PASS_PG_STAGING }} | ||
CLOUDSQL_CONN_PG: $GCP_PROJECT_ID:$GCP_ZONE:$SQL_INST_PG | ||
CLOUDSQL_CONN: $GCP_PROJECT_ID:$GCP_ZONE:$SQL_INST | ||
|
||
# - name: Upload coverage to Codecov | ||
# uses: codecov/codecov-action@v1 | ||
# with: | ||
# token: ${{ secrets.CODECOV_TOKEN }} | ||
# directory: ./ | ||
# flags: unittests | ||
# env_vars: OS,PYTHON | ||
# name: codecov-umbrella | ||
# fail_ci_if_error: false | ||
# path_to_write_report: ./coverage/codecov_report.txt | ||
# verbose: true |
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,22 @@ | ||
name: Mark stale issues and pull requests | ||
|
||
on: | ||
schedule: | ||
- cron: '22 22 * * *' | ||
|
||
jobs: | ||
stale: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
pull-requests: write | ||
|
||
steps: | ||
- uses: actions/stale@v3 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
stale-issue-message: 'Stale issue message' | ||
stale-pr-message: 'Stale pull request message' | ||
stale-issue-label: 'no-issue-activity' | ||
stale-pr-label: 'no-pr-activity' |
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,29 @@ | ||
from app.crud import contact | ||
|
||
def test_isSubscribed_1(): | ||
result = contact.isSubscribed("", ['']) | ||
assert result is False | ||
|
||
def test_isSubscribed_2(): | ||
result = contact.isSubscribed("", ['subscribed_emails_local_host', 'subscribed_emails_movement_information', 'subscribed_emails_weekly_letter', 'subscribed_emails_referents', 'citizen_project_host_email', 'subscribed_emails_citizen_project_creation', 'deputy_email', 'candidate_email', 'senator_email']) | ||
assert result is False | ||
|
||
def test_isSubscribed_3(): | ||
result = contact.isSubscribed("fake_role", ['subscribed_emails_local_host', 'subscribed_emails_movement_information', 'subscribed_emails_weekly_letter', 'subscribed_emails_referents', 'citizen_project_host_email', 'subscribed_emails_citizen_project_creation', 'deputy_email', 'candidate_email', 'senator_email']) | ||
assert result is False | ||
|
||
def test_isSubscribed_4(): | ||
result = contact.isSubscribed("referent", ['subscribed_emails_local_host', 'subscribed_emails_movement_information', 'subscribed_emails_weekly_letter', 'subscribed_emails_referents', 'citizen_project_host_email', 'subscribed_emails_citizen_project_creation', 'deputy_email', 'candidate_email', 'senator_email']) | ||
assert result is True | ||
|
||
def test_isSubscribed_5(): | ||
result = contact.isSubscribed("referent", ['subscribed_emails_local_host', 'subscribed_emails_movement_information', 'subscribed_emails_weekly_letter', 'citizen_project_host_email', 'subscribed_emails_citizen_project_creation', 'deputy_email', 'candidate_email', 'senator_email']) | ||
assert result is False | ||
|
||
def test_isSubscribed_6(): | ||
result = contact.isSubscribed("referent", ['subscribed_emails_referents']) | ||
assert result is True | ||
|
||
def test_isSubscribed_7(): | ||
result = contact.isSubscribed("referent", ['']) | ||
assert result is False |