Skip to content

Commit b8df016

Browse files
author
SteveT
authored
Merge pull request #215 from darrensmith223/bug-fix
Fix bug in _translate_keys that affects non-nested parameters
2 parents 7f1dc2b + 5bec57e commit b8df016

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

sparkpost/transmissions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def _translate_keys(self, **kwargs):
6262
if from_key in model:
6363
to_model = model
6464
to_key = model_remap[from_key]
65-
if to_key.index('/'):
65+
if '/' in to_key:
6666
# Nested within a dict
6767
into_list = to_key.split('/')
6868
to_key = into_list[-1]

test/test_transmissions.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ def test_translate_keys_for_from_email():
6666
}
6767

6868

69+
@responses.activate
70+
def test_campaign_id():
71+
responses.add(
72+
responses.POST,
73+
'https://api.sparkpost.com/api/v1/transmissions',
74+
status=200,
75+
content_type='application/json',
76+
body='{"results": "yay"}'
77+
)
78+
sp = SparkPost('fake-key')
79+
results = sp.transmission.send(campaign="test")
80+
assert results == 'yay'
81+
82+
6983
def test_format_header_to():
7084
t = Transmissions('uri', 'key')
7185
formatted = t._format_header_to(recipient={

0 commit comments

Comments
 (0)