-
Notifications
You must be signed in to change notification settings - Fork 2
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 #219 from fecgov/release/sprint-13
Release/sprint 13
- Loading branch information
Showing
27 changed files
with
504 additions
and
18 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
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,7 +1,6 @@ | ||
cd django-backend | ||
|
||
# Run migrations | ||
./manage.py migrate --noinput > migrate.out | ||
|
||
# Run application | ||
python wait_for_db.py && gunicorn --bind 0.0.0.0:8080 fecfiler.wsgi -w 9 -t 200 | ||
# Run migrations and application | ||
./manage.py migrate --no-input --traceback --verbosity 3 > migrate.out && | ||
python wait_for_db.py && | ||
gunicorn --bind 0.0.0.0:8080 fecfiler.wsgi -w 9 -t 200 |
Empty file.
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,36 @@ | ||
import unittest | ||
from unittest.mock import Mock | ||
|
||
|
||
from django.test import RequestFactory | ||
|
||
from fecfiler.authentication.token import (login_dot_gov_logout, | ||
generate_username) | ||
|
||
|
||
class TestToken(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.factory = RequestFactory() | ||
|
||
def test_login_dot_gov_logout_happy_path(self): | ||
test_id_token_hint = 'test_id_token_hint' | ||
test_state = 'test_state' | ||
|
||
mock_request = Mock() | ||
mock_request.session = Mock() | ||
mock_request.session.get.return_value = test_id_token_hint | ||
mock_request.get_signed_cookie.return_value = test_state | ||
|
||
retval = login_dot_gov_logout(mock_request) | ||
self.maxDiff = None | ||
self.assertEqual(retval, ('https://idp.int.identitysandbox.gov' | ||
'/openid_connect/logout?' | ||
'id_token_hint=test_id_token_hint' | ||
'&post_logout_redirect_uri=None' | ||
'&state=test_state')) | ||
|
||
def test_generate_username(self): | ||
test_uuid = 'test_uuid' | ||
retval = generate_username(test_uuid) | ||
self.assertEqual(test_uuid, retval) |
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,51 @@ | ||
from django.test import TestCase, RequestFactory | ||
from .views import ContactViewSet | ||
from ..authentication.models import Account | ||
from unittest import mock | ||
|
||
|
||
def mocked_requests_get(*args, **kwargs): | ||
class MockResponse: | ||
def __init__(self, json_data, status_code): | ||
self.json_data = json_data | ||
self.status_code = status_code | ||
|
||
def json(self): | ||
return self.json_data | ||
|
||
return MockResponse( | ||
{ | ||
"results": [ | ||
{"name": "BIDEN FOR PRESIDENT", "id": "C00703975", "is_active": "true"}, | ||
{"name": "BIDEN VICTORY FUND", "id": "C00744946", "is_active": "true"}, | ||
] | ||
}, | ||
200, | ||
) | ||
|
||
|
||
class ContactViewSetTest(TestCase): | ||
fixtures = ["test_contacts", "test_committee_accounts", "test_accounts"] | ||
|
||
def setUp(self): | ||
self.user = Account.objects.get(cmtee_id="C12345678") | ||
self.factory = RequestFactory() | ||
|
||
@mock.patch("requests.get", side_effect=mocked_requests_get) | ||
def test_committee_lookup_happy_path(self, mock_get): | ||
self.assertEqual(True, True) | ||
request = self.factory.get("/api/v1/contacts/committee_lookup") | ||
request.user = self.user | ||
|
||
response = ContactViewSet.as_view({"get": "committee_lookup"})(request) | ||
|
||
expected_json = { | ||
"fec_api_committees": [ | ||
{"name": "BIDEN FOR PRESIDENT", "id": "C00703975", "is_active": "true"}, | ||
{"name": "BIDEN VICTORY FUND", "id": "C00744946", "is_active": "true"}, | ||
], | ||
"fecfile_committees": [], | ||
} | ||
|
||
self.assertEqual(response.status_code, 200) | ||
self.assertJSONEqual(str(response.content, encoding="utf8"), expected_json) |
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,11 @@ | ||
"""Django App for F3X Reports | ||
Provides F3X Summary record | ||
:py:class:`fecfiler.f3x_summaries.models.F3XSummary` | ||
Also provides abstract model and viewset for | ||
apps that need report-related records | ||
:py:class:`fecfiler.committee_accounts.models.ReportMixin` | ||
:py:class:`fecfiler.committee_accounts.views.ReportViewMixin` | ||
""" |
62 changes: 62 additions & 0 deletions
62
django-backend/fecfiler/f3x_summaries/fixtures/test_summary_transactions.json
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,62 @@ | ||
[ | ||
{ | ||
"comment": "SA15 transaction to count", | ||
"model": "scha_transactions.schatransaction", | ||
"fields": { | ||
"id": 9999, | ||
"committee_account_id": 1000, | ||
"report_id":9999, | ||
"form_type": "SA15", | ||
"contribution_amount":1234.56, | ||
"memo_code": false, | ||
"created": "2022-02-09T00:00:00.000Z", | ||
"updated": "2022-02-09T00:00:00.000Z", | ||
"transaction_type_identifier":"OFFSET_TO_OPEX" | ||
} | ||
}, | ||
{ | ||
"comment": "SA15 transaction to count", | ||
"model": "scha_transactions.schatransaction", | ||
"fields": { | ||
"id": 10000, | ||
"committee_account_id": 1000, | ||
"report_id":9999, | ||
"form_type": "SA15", | ||
"contribution_amount":891.23, | ||
"memo_code": false, | ||
"created": "2022-02-09T00:00:00.000Z", | ||
"updated": "2022-02-09T00:00:00.000Z", | ||
"transaction_type_identifier":"OFFSET_TO_OPEX" | ||
} | ||
}, | ||
{ | ||
"comment": "SA15 transaction to NOT count", | ||
"model": "scha_transactions.schatransaction", | ||
"fields": { | ||
"id": 10001, | ||
"committee_account_id": 1000, | ||
"report_id":9999, | ||
"form_type": "SA15", | ||
"contribution_amount":10000.23, | ||
"memo_code": true, | ||
"created": "2022-02-09T00:00:00.000Z", | ||
"updated": "2022-02-09T00:00:00.000Z", | ||
"transaction_type_identifier":"OFFSET_TO_OPEX" | ||
} | ||
}, | ||
{ | ||
"comment": "SA11AI transaction to NOT count with SA15", | ||
"model": "scha_transactions.schatransaction", | ||
"fields": { | ||
"id": 10002, | ||
"committee_account_id": 1000, | ||
"report_id":9999, | ||
"form_type": "SA11AI", | ||
"contribution_amount":10000.23, | ||
"memo_code": false, | ||
"created": "2022-02-09T00:00:00.000Z", | ||
"updated": "2022-02-09T00:00:00.000Z", | ||
"transaction_type_identifier":"INDV_REC" | ||
} | ||
} | ||
] |
18 changes: 18 additions & 0 deletions
18
django-backend/fecfiler/f3x_summaries/migrations/0017_f3xsummary_calculation_status.py
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,18 @@ | ||
# Generated by Django 3.2.12 on 2022-09-01 20:59 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('f3x_summaries', '0016_f3xsummary_webprint_submission'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='f3xsummary', | ||
name='calculation_status', | ||
field=models.CharField(blank=True, max_length=255, null=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
Oops, something went wrong.