8
8
9
9
10
10
# This method will be used by the mock to replace requests.get / requests.post
11
- def mocked_requests_call (target ):
11
+ def mocked_requests_call (target , ** kwargs ):
12
12
class MockResponse :
13
13
def __init__ (self , status_code , data ):
14
14
self .status_code = status_code
@@ -87,7 +87,7 @@ def test_user_create_error(_):
87
87
88
88
89
89
@mock .patch ('adobe_umapi.api.requests.post' , side_effect = mocked_requests_call )
90
- def test_user_create_success (_ ):
90
+ def test_user_create_failure (_ ):
91
91
"""Test User Creation - FAILURE"""
92
92
auth = mock .create_autospec (Auth )
93
93
@@ -128,23 +128,26 @@ def test_action_obj_create():
128
128
action = Action (
user_key = "[email protected] " ).
do (
129
129
addAdobeID = {
"email" :
"[email protected] " }
130
130
)
131
- assert json .
dumps (
action .
data )
== '{"do": [{"addAdobeID": {"email": "[email protected] "}}], "user": "[email protected] "}'
131
+ assert json .dumps (action .data , sort_keys = True ) == \
132
+ '{"do": [{"addAdobeID": {"email": "[email protected] "}}], "user": "[email protected] "}'
132
133
133
134
134
135
def test_action_obj_remove ():
135
136
""""Create a user removal action object"""
136
137
action = Action (
user_key = "[email protected] " ).
do (
137
138
removeFromOrg = {}
138
139
)
139
- assert json .
dumps (
action .
data )
== '{"do": [{"removeFromOrg": {}}], "user": "[email protected] "}'
140
+ assert json .dumps (action .data , sort_keys = True ) == \
141
+ '{"do": [{"removeFromOrg": {}}], "user": "[email protected] "}'
140
142
141
143
142
144
def test_action_obj_update ():
143
145
"""Create a user update action object"""
144
146
action = Action (
user_key = "[email protected] " ).
do (
145
147
update = {"firstname" : "example" , "lastname" : "user" }
146
148
)
147
- assert json .
dumps (
action .
data )
== '{"do": [{"update": {"lastname": "user", "firstname": "example"}}], "user": "[email protected] "}'
149
+ assert json .dumps (action .data , sort_keys = True ) == \
150
+ '{"do": [{"update": {"firstname": "example", "lastname": "user"}}], "user": "[email protected] "}'
148
151
149
152
150
153
def test_action_obj_multi ():
@@ -154,12 +157,14 @@ def test_action_obj_multi():
154
157
add = ["product1" , "product2" ],
155
158
remove = ["product3" ]
156
159
)
157
- assert json .
dumps (
action .
data )
== '{"do": [{"addAdobeID": {"email": "[email protected] "}}, {"add": {"product": ["product1", "product2"]}}, {"remove": {"product": ["product3"]}}], "user": "[email protected] "}'
160
+ assert json .dumps (action .data , sort_keys = True ) == \
161
+ '{"do": [{"addAdobeID": {"email": "[email protected] "}}, {"add": {"product": ["product1", "product2"]}}, {"remove": {"product": ["product3"]}}], "user": "[email protected] "}'
158
162
159
163
160
164
def test_action_obj_requestid ():
161
165
"""Include a request ID in action object"""
162
166
action = Action (
user_key = "[email protected] " ,
requestID = "abc123" ).
do (
163
167
add = ["product1" ]
164
168
)
165
- assert json .
dumps (
action .
data )
== '{"do": [{"add": {"product": ["product1"]}}], "user": "[email protected] ", "requestID": "abc123"}'
169
+ assert json .dumps (action .data , sort_keys = True ) == \
170
+ '{"do": [{"add": {"product": ["product1"]}}], "requestID": "abc123", "user": "[email protected] "}'
0 commit comments