@@ -78,7 +78,7 @@ class TestGetStats(object):
78
78
def test_get_stats (self , dynamic_links_test ):
79
79
_ , recorder = dynamic_links_test ._instrument_dynamic_links (
80
80
payload = MOCK_GET_STATS_RESPONSE )
81
- options = dynamic_links .StatOptions (duration_days = 9 )
81
+ options = dynamic_links .StatOptions (last_n_days = 9 )
82
82
link_stats = dynamic_links .get_link_stats (
83
83
MOCK_SHORT_URL , options , app = dynamic_links_test .app )
84
84
assert recorder [0 ].url .startswith ('https://firebasedynamiclinks.googleapis.com' )
@@ -96,7 +96,7 @@ def test_get_stats(self, dynamic_links_test):
96
96
97
97
@pytest .mark .parametrize ('error_code' , [400 , 401 , 500 ])
98
98
def test_server_error (self , dynamic_links_test , error_code ):
99
- options = dynamic_links .StatOptions (duration_days = 9 )
99
+ options = dynamic_links .StatOptions (last_n_days = 9 )
100
100
dynamic_links_test ._instrument_dynamic_links (
101
101
payload = json .dumps ({'error' : {
102
102
'status' : 'INTERNAL_ERROR' ,
@@ -111,7 +111,7 @@ def test_server_error(self, dynamic_links_test, error_code):
111
111
112
112
@pytest .mark .parametrize ('error_code' , [400 , 401 , 500 ])
113
113
def test_server_unformatted_error (self , dynamic_links_test , error_code ):
114
- options = dynamic_links .StatOptions (duration_days = 9 )
114
+ options = dynamic_links .StatOptions (last_n_days = 9 )
115
115
dynamic_links_test ._instrument_dynamic_links (
116
116
payload = 'custom error message' ,
117
117
status = error_code )
@@ -122,7 +122,7 @@ def test_server_unformatted_error(self, dynamic_links_test, error_code):
122
122
assert excinfo .value .code == dynamic_links ._UNKNOWN_ERROR
123
123
124
124
def test_server_non_payload_error (self , dynamic_links_test ):
125
- options = dynamic_links .StatOptions (duration_days = 9 )
125
+ options = dynamic_links .StatOptions (last_n_days = 9 )
126
126
dynamic_links_test ._instrument_dynamic_links (
127
127
payload = '' ,
128
128
status = 400 )
@@ -135,30 +135,30 @@ def test_server_non_payload_error(self, dynamic_links_test):
135
135
136
136
@pytest .mark .parametrize ('invalid_url' , ['google.com' ] + INVALID_STRINGS )
137
137
def test_get_stats_invalid_url (self , dynamic_links_test , invalid_url ):
138
- options = dynamic_links .StatOptions (duration_days = 9 )
138
+ options = dynamic_links .StatOptions (last_n_days = 9 )
139
139
with pytest .raises (ValueError ) as excinfo :
140
140
dynamic_links .get_link_stats (invalid_url , options , app = dynamic_links_test .app )
141
141
assert 'short_link must be a string and begin with "https://".' in str (excinfo .value )
142
-
142
+
143
143
@pytest .mark .parametrize ('invalid_options' , INVALID_STRINGS )
144
144
def test_get_stats_invalid_options (self , dynamic_links_test , invalid_options ):
145
145
with pytest .raises (ValueError ) as excinfo :
146
146
dynamic_links .get_link_stats (
147
147
MOCK_SHORT_URL , invalid_options , app = dynamic_links_test .app )
148
148
assert 'stat_options must be of type StatOptions.' in str (excinfo .value )
149
-
149
+
150
150
@pytest .mark .parametrize ('invalid_duration' , [0 ] + INVALID_NON_NEGATIVE_NUMS )
151
- def test_get_stats_invalid_duration_days (self , invalid_duration ):
151
+ def test_get_stats_invalid_last_n_days (self , invalid_duration ):
152
152
with pytest .raises (ValueError ) as excinfo :
153
- dynamic_links .StatOptions (duration_days = invalid_duration )
154
- assert 'duration_days ' in str (excinfo .value )
153
+ dynamic_links .StatOptions (last_n_days = invalid_duration )
154
+ assert 'last_n_days ' in str (excinfo .value )
155
155
assert 'must be positive int' in str (excinfo .value )
156
156
157
157
158
158
class TestEventStats (object ):
159
159
@pytest .mark .parametrize ('platform, event' ,
160
- itertools .product (dynamic_links ._platforms .keys (),
161
- dynamic_links ._event_types .keys ()))
160
+ itertools .product (dynamic_links ._platforms .keys (),
161
+ dynamic_links ._event_types .keys ()))
162
162
def test_valid_platform_values (self , platform , event ):
163
163
event_stats = dynamic_links .EventStats (
164
164
platform = platform ,
0 commit comments