FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sendgrid-python/test/test_stats.py at main · animerawk01/sendgrid-python · GitHub
animerawk01
/
sendgrid-python
Public
forked from
sendgrid/sendgrid-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sendgrid-python
/
test
/
test_stats.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
86 lines (70 loc) · 2.78 KB
Breadcrumbs
sendgrid-python
/
test
/
test_stats.py
Copy path
File metadata and controls
86 lines (70 loc) · 2.78 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
81
82
83
84
85
86
# -*- coding: utf-8 -*-
import
json
from
sendgrid
.
helpers
.
stats
import
*
try
:
import
unittest2
as
unittest
except
ImportError
:
import
unittest
class
UnitTests
(
unittest
.
TestCase
):
def
test_basicStats
(
self
):
"""Minimum required for stats"""
global_stats
=
Stats
(
start_date
=
'12-09-2017'
)
self
.
assertEqual
(
json
.
dumps
(
global_stats
.
get
(),
sort_keys
=
True
),
'{"start_date": "12-09-2017"}'
)
self
.
assertTrue
(
isinstance
(
str
(
global_stats
),
str
))
def
test_Stats
(
self
):
all_stats
=
Stats
(
start_date
=
'12-09-2017'
)
all_stats
.
end_date
=
'12-10-2017'
all_stats
.
aggregated_by
=
'day'
all_stats
.
_sort_by_direction
=
'asc'
all_stats
.
sort_by_metric
=
'clicks'
all_stats
.
_limit
=
100
all_stats
.
_offset
=
2
self
.
assertEqual
(
json
.
dumps
(
all_stats
.
get
(),
sort_keys
=
True
),
'{"aggregated_by": "day", "end_date": "12-10-2017", '
'"limit": 100, "offset": 2, "sort_by_direction": "asc", '
'"sort_by_metric": "clicks", "start_date": "12-09-2017"}'
)
def
test_categoryStats
(
self
):
category_stats
=
CategoryStats
(
start_date
=
'12-09-2017'
,
categories
=
[
'foo'
,
'bar'
])
category_stats
.
add_category
(
Category
(
'woo'
))
category_stats
.
end_date
=
'12-10-2017'
category_stats
.
aggregated_by
=
'day'
category_stats
.
_sort_by_direction
=
'asc'
category_stats
.
sort_by_metric
=
'clicks'
category_stats
.
_limit
=
100
category_stats
.
_offset
=
2
self
.
assertEqual
(
json
.
dumps
(
category_stats
.
get
(),
sort_keys
=
True
),
'{"aggregated_by": "day", "categories": ["foo", "bar", "woo"], '
'"end_date": "12-10-2017", "limit": 100, "offset": 2, '
'"sort_by_direction": "asc", "sort_by_metric": "clicks", '
'"start_date": "12-09-2017"}'
)
def
test_subuserStats
(
self
):
subuser_stats
=
SubuserStats
(
start_date
=
'12-09-2017'
,
subusers
=
[
'foo'
,
'bar'
])
subuser_stats
.
add_subuser
(
Subuser
(
'blah'
))
subuser_stats
.
end_date
=
'12-10-2017'
subuser_stats
.
aggregated_by
=
'day'
subuser_stats
.
_sort_by_direction
=
'asc'
subuser_stats
.
sort_by_metric
=
'clicks'
subuser_stats
.
_limit
=
100
subuser_stats
.
_offset
=
2
self
.
assertEqual
(
json
.
dumps
(
subuser_stats
.
get
(),
sort_keys
=
True
),
'{"aggregated_by": "day", "end_date": "12-10-2017", '
'"limit": 100, "offset": 2, "sort_by_direction": "asc", '
'"sort_by_metric": "clicks", "start_date": "12-09-2017", '
'"subusers": ["foo", "bar", "blah"]}'
)
Back
|
FazBrowse Home
|
New Git URL