-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtests.py
80 lines (71 loc) · 2.65 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
""" super simple tests """
import os
import mail_script
import requests
from jinja2 import Template, Environment, FileSystemLoader
jinja_environment = Environment(autoescape=True,loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')))
test_filing = {
'date': 'today',
'committees': [
{
'committee_name': 'test committee',
'committee_id': '123',
'committee_name': 'Lindsay\'s fictional committee',
'filings': [
{
'candidate_name': '',
'file_number': '123456',
'amendment_indicator': 'N',
'report_type': 'F3',
'report_type_full': 'Sept Quarterly',
'total_receipts': '1000',
'total_disbursements': '5000',
'total_independent_expenditures': '23',
'receipt_date': '08/30/2016',
'coverage_start_date': '07/01/2016',
'coverage_end_date': '08/30/2016',
'url': 'www.example.com',
},
{
'candidate_name': 'person',
'file_number': '12346',
'amendment_indicator': 'N',
'report_type': 'F3',
'report_type_full': 'Sept Quarterly',
'total_receipts': '1000',
'total_disbursements': '5000',
'total_independent_expenditures': '23',
'receipt_date': '08/30/2016',
'coverage_start_date': '07/01/2016',
'coverage_end_date': '08/30/2016',
'url': 'www.example.com',
},
]
}
]
}
def test_email_render():
template = jinja_environment.get_template('test_template.html')
text = template.render(test_filing)
print(text)
def test_email(data):
server = mail_script.email_log_in()
mail_script.mail_update(server, data, os.environ['ADMIN_EMAIL'])
test_email_render()
test_email(test_filing)
# data = (r['sub_id'], # primary key
# r['committee_id'],
# r['committee_name'],
# r['candidate_name']
# r['file_number'],
# r['amendment_indicator'],
# r['report_type']
# r['report_type_full'],
# r['total_receipts'],
# r['total_disbursements'],
# r['total_independent_expenditures'],
# r['receipt_date'],
# r['coverage_start_date'],
# r['coverage_end_date'],
# r['pages'],
# 'http://docquery.fec.gov/dcdev/posted/{0}.fec'.format(r['file_number'])