8000 six · ClarkDing/firebase-admin-python@edce127 · GitHub
[go: up one dir, main page]

Skip to content

Commit edce127

Browse files
committed
six
1 parent fb68d14 commit edce127

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

firebase_admin/dynamic_links.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ def platform(self):
165165

166166
@platform.setter
167167
def platform(self, platform):
168-
if platform in self._platforms.keys():
168+
if isinstance(platform, str) and platform in self._platforms.keys():
169169
raise ValueError(('Raw string {} detected. Use one of the dynamic_links.PLATFORM_...' +
170170
' constants, or the from_json() method.').format(platform))
171-
if platform not in self._platforms.values():
171+
if not isinstance(platform, str) or platform not in self._platforms.values():
172172
raise ValueError('platform {}, not recognized'.format(platform))
173173
self._platform = platform
174174

@@ -178,10 +178,10 @@ def event(self):
178178

179179
@event.setter
180180
def event(self, event):
181-
if event in self._event_types.keys():
181+
if isinstance(event, str) and event in self._event_types.keys():
182182
raise ValueError(('Raw string {} detected. Use one of the dynamic_links.EVENT_TYPES_' +
183183
' constants, or the from_json() method.').format(event))
184-
if event not in self._event_types.values():
184+
if not isinstance(event, str) or event not in self._event_types.values():
185185
raise ValueError('event_type {}, not recognized'.format(event))
186186
self._event = event
187187

tests/test_dynamic_links.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,21 @@ def test_get_stats_invalid_url(self, dltest, invalid_url):
102102
options = dynamic_links.StatOptions(duration_days=9)
103103
with pytest.raises(ValueError) as excinfo:
104104
dynamic_links.get_link_stats(invalid_url, options, app=dltest.app)
105-
assert 'Url must be a string and begin with "https://".' in excinfo.value.message
105+
assert 'Url must be a string and begin w 8000 ith "https://".' in str(excinfo.value)
106106

107107
@pytest.mark.parametrize('invalid_options', INVALID_STRINGS)
108108
def test_get_stats_invalid_options(self, dltest, invalid_options):
109109
with pytest.raises(ValueError) as excinfo:
110110
dynamic_links.get_link_stats(_MOCK_SHORT_URL, invalid_options, app=dltest.app)
111-
assert 'Options must be of type StatOptions.' in excinfo.value.message
111+
assert 'Options must be of type StatOptions.' in str(excinfo.value)
112112

113113
@pytest.mark.parametrize('invalid_duration', [0] + INVALID_NON_NEGATIVE_NUMS)
114114
def test_get_stats_invalid_duration_days(self, dltest, invalid_duration):
115115
options = dynamic_links.StatOptions(duration_days=invalid_duration)
116116
with pytest.raises(ValueError) as excinfo:
117117
dynamic_links.get_link_stats(_MOCK_SHORT_URL, options, app=dltest.app)
118-
assert 'duration_days' in excinfo.value.message
119-
assert 'must be positive int' in excinfo.value.message
118+
assert 'duration_days' in str(excinfo.value)
119+
assert 'must be positive int' in str(excinfo.value)
120120

121121

122122
class TestEventStats(object):
@@ -135,7 +135,7 @@ def test_invalid_platform_values(self, arg):
135135
8000 platform=arg,
136136
event=dynamic_links.EVENT_TYPE_CLICK,
137137
count=1)
138-
assert 'not recognized' in excinfo.value.message
138+
assert 'not recognized' in str(excinfo.value)
139139

140140
@pytest.mark.parametrize('arg', dynamic_links.EventStats._platforms.keys())
141141
def test_raw_platform_values_invalid(self, arg):
@@ -144,7 +144,7 @@ def test_raw_platform_values_invalid(self, arg):
144144
platform=arg,
145145
event=dynamic_links.EVENT_TYPE_CLICK,
146146
count=1)
147-
assert 'Raw string' in excinfo.value.message
147+
assert 'Raw string' in str(excinfo.value)
148148

149149
@pytest.mark.parametrize('event', dynamic_links.EventStats._event_types.keys())
150150
def test_valid_event_values(self, event):
@@ -161,7 +161,7 @@ def test_invalid_event_values(self, arg):
161161
platform=dynamic_links.PLATFORM_ANDROID,
162162
event=arg,
163163
count=1)
164-
assert 'not recognized' in excinfo.value.message
164+
assert 'not recognized' in str(excinfo.value)
165165

166166
@pytest.mark.parametrize('arg', dynamic_links.EventStats._event_types.keys())
167167
def test_raw_event_values_invalid(self, arg):
@@ -170,7 +170,7 @@ def test_raw_event_values_invalid(self, arg):
170170
platform=dynamic_links.PLATFORM_ANDROID,
171171
event=arg,
172172
count=1)
173-
assert 'Raw string' in excinfo.value.message
173+
assert 'Raw string' in str(excinfo.value)
174174

175175
@pytest.mark.parametrize('count', [1, 123, 1234])
176176
def test_valid_count_values(self, count):
@@ -187,21 +187,21 @@ def test_invalid_count_values(self, arg):
187187
platform=dynamic_links.PLATFORM_ANDROID,
188188
event=dynamic_links.EVENT_TYPE_CLICK,
189189
count=arg)
190-
assert 'must be a non negative int' in excinfo.value.message
190+
assert 'must be a non negative int' in str(excinfo.value)
191191

192192

193193
class TestLinkStatsCreation(object):
194194
@pytest.mark.parametrize('arg', INVALID_LISTS)
195195
def test_invalid_event_stats_list(self, arg):
196196
with pytest.raises(ValueError) as excinfo:
197197
dynamic_links.LinkStats(arg)
198-
assert'Must be a list or tuple' in excinfo.value.message
198+
assert'Must be a list or tuple' in str(excinfo.value)
199199

200200
@pytest.mark.parametrize('arg', [list([1,2]), list('asdf'), tuple([1,2])])
201201
def test_empty_event_stats_list(self, arg):
202202
with pytest.raises(ValueError) as excinfo:
203203
dynamic_links.LinkStats(arg)
204-
assert'elements of event stats must be "EventStats"' in excinfo.value.message
204+
assert'elements of event stats must be "EventStats"' in str(excinfo.value)
205205

206206

207207
class TestQuoting(object):

0 commit comments

Comments
 (0)
0