Skip to content

Commit 6298af5

Browse files
committed
Fix various tests
1 parent 00d4461 commit 6298af5

7 files changed

Lines changed: 56 additions & 70 deletions

File tree

identify/main/identify_sync_client.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ def delete_attribute_from_schema(self, traffic_type_id, attribute_id):
9292
'''
9393
return Attribute.delete(self._client, attribute_id, traffic_type_id)
9494

95-
def add_identities(self, traffic_type_id, environment_id, identities,
96-
organization_id=None):
95+
def add_identities(self, traffic_type_id, environment_id, identities):
9796
'''
9897
Create Identities for a specific traffic type and environment.
9998
@@ -117,11 +116,9 @@ def add_identities(self, traffic_type_id, environment_id, identities,
117116
traffic_type_id,
118117
environment_id,
119118
identities,
120-
organization_id
121119
)
122120

123-
def add_identity(self, traffic_type_id, environment_id, key, values,
124-
organization_id=None):
121+
def add_identity(self, traffic_type_id, environment_id, key, values):
125122
'''
126123
Create a new Identity.
127124
@@ -140,12 +137,10 @@ def add_identity(self, traffic_type_id, environment_id, key, values,
140137
key,
141138
traffic_type_id,
142139
environment_id,
143-
values,
144-
organization_id
140+
values
145141
)
146142

147-
def update_identity(self, traffic_type_id, environment_id, key, values,
148-
organization_id=None):
143+
def update_identity(self, traffic_type_id, environment_id, key, values):
149144
'''
150145
Update an Identity.
151146
@@ -164,12 +159,10 @@ def update_identity(self, traffic_type_id, environment_id, key, values,
164159
key,
165160
traffic_type_id,
166161
environment_id,
167-
values,
168-
organization_id
162+
values
169163
)
170164

171-
def patch_identity(self, traffic_type_id, environment_id, key, values,
172-
organization_id=None):
165+
def patch_identity(self, traffic_type_id, environment_id, key, values):
173166
'''
174167
Patch an Identity.
175168
@@ -188,8 +181,7 @@ def patch_identity(self, traffic_type_id, environment_id, key, values,
188181
key,
189182
traffic_type_id,
190183
environment_id,
191-
values,
192-
organization_id
184+
values
193185
)
194186

195187
def delete_attributes_from_key(self, traffic_type_id, environment_id, key):

identify/resources/attribute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Attribute(BaseResource):
5151
'displayName': 'string',
5252
'description': 'string',
5353
'dataType': 'string',
54-
'isSearchable': 'string',
54+
'isSearchable': 'bool',
5555
}
5656

5757
def __init__(self, client, id, traffic_type_id, display_name=None,

identify/resources/identity.py

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,17 @@ class Identity(BaseResource):
7777
'trafficTypeId': 'string',
7878
'environmentId': 'string',
7979
'values': 'object',
80-
'organizationId': 'string',
81-
'timestamp': 'string',
8280
}
8381

8482
def __init__(self, client, key, traffic_type_id, environment_id,
85-
values=None, organization_id=None, timestamp=None):
83+
values=None):
8684
'''
8785
'''
8886
BaseResource.__init__(self, client, key)
8987
self._traffic_type_id = traffic_type_id
9088
self._key = key
9189
self._environment_id = environment_id
9290
self._values = values
93-
self._organization_id = organization_id
94-
self._timestamp = timestamp
9591

9692
@property
9793
def key(self):
@@ -109,23 +105,14 @@ def environment_id(self):
109105
def values(self):
110106
return self._values
111107

112-
@property
113-
def organization_id(self):
114-
return self._organization_id
115-
116-
@property
117-
def timestamp(self):
118-
return self._timestamp
119-
120108
@classmethod
121109
def _build_single_from_collection_response(cls, client, response):
122110
'''
123111
'''
124112
raise MethodNotApplicable()
125113

126114
@classmethod
127-
def create(cls, client, key, traffic_type_id, environment_id, values,
128-
organization_id=None):
115+
def create(cls, client, key, traffic_type_id, environment_id, values):
129116
'''
130117
'''
131118
try:
@@ -135,7 +122,6 @@ def create(cls, client, key, traffic_type_id, environment_id, values,
135122
'key': key,
136123
'trafficTypeId': traffic_type_id,
137124
'environmentId': environment_id,
138-
'organization_id': organization_id,
139125
'values': values
140126
},
141127
key=key,
@@ -155,13 +141,10 @@ def create(cls, client, key, traffic_type_id, environment_id, values,
155141
response['trafficTypeId'],
156142
response['environmentId'],
157143
response['values'],
158-
response['organizationId'],
159-
response['timestamp']
160144
)
161145

162146
@classmethod
163-
def create_many(cls, client, traffic_type_id, environment_id, identities,
164-
organization_id=None):
147+
def create_many(cls, client, traffic_type_id, environment_id, identities):
165148
'''
166149
entities: { key: { attr_id: value, ...} }
167150
'''
@@ -174,7 +157,6 @@ def create_many(cls, client, traffic_type_id, environment_id, identities,
174157
'key': key,
175158
'trafficTypeId': traffic_type_id,
176159
'environmentId': environment_id,
177-
'organizationId': organization_id,
178160
'values': identities[key]
179161
}
180162
for key in identities.keys()
@@ -186,8 +168,7 @@ def create_many(cls, client, traffic_type_id, environment_id, identities,
186168
successful = [
187169
Identity(
188170
client, i['key'], i['trafficTypeId'],
189-
i['environmentId'], i['values'], i['organizationId'],
190-
i['timestamp']
171+
i['environmentId'], i['values']
191172
) for i in response['objects']
192173
]
193174

@@ -199,8 +180,6 @@ def create_many(cls, client, traffic_type_id, environment_id, identities,
199180
i['object']['trafficTypeId'],
200181
i['object']['environmentId'],
201182
i['object']['values'],
202-
i['object']['organizationId'],
203-
i['object']['timestamp']
204183
),
205184
'status': i['status'],
206185
'message': i['message']
@@ -218,8 +197,7 @@ def create_many(cls, client, traffic_type_id, environment_id, identities,
218197
raise UnknownIdentifyClientError()
219198

220199
@classmethod
221-
def update(cls, client, key, traffic_type_id, environment_id, values,
222-
organization_id):
200+
def update(cls, client, key, traffic_type_id, environment_id, values):
223201
'''
224202
'''
225203
try:
@@ -229,7 +207,6 @@ def update(cls, client, key, traffic_type_id, environment_id, values,
229207
'key': key,
230208
'trafficTypeId': traffic_type_id,
231209
'environmentId': environment_id,
232-
'organizationId': organization_id,
233210
'values': values
234211
},
235212
key=key,
@@ -249,12 +226,10 @@ def update(cls, client, key, traffic_type_id, environment_id, values,
249226
response['trafficTypeId'],
250227
response['environmentId'],
251228
response['values'],
252-
response['timestamp']
253229
)
254230

255231
@classmethod
256-
def patch(cls, client, key, traffic_type_id, environment_id, values,
257-
organization_id):
232+
def patch(cls, client, key, traffic_type_id, environment_id, values):
258233
'''
259234
'''
260235
try:
@@ -264,7 +239,6 @@ def patch(cls, client, key, traffic_type_id, environment_id, values,
264239
'key': key,
265240
'trafficTypeId': traffic_type_id,
266241
'environmentId': environment_id,
267-
'organizationId': organization_id,
268242
'values': values
269243
},
270244
key=key,
@@ -284,8 +258,6 @@ def patch(cls, client, key, traffic_type_id, environment_id, values,
284258
response['trafficTypeId'],
285259
response['environmentId'],
286260
response['values'],
287-
response['organization_id'],
288-
response['timestamp']
289261
)
290262

291263
@classmethod

identify/tests/e2e/e2etests.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def test_traffic_type_endpoint(self):
2929
'''
3030
c = get_client({
3131
'base_url': 'http://localhost:8888',
32-
'apikey': 'Admin'
32+
'apikey': 'Admin',
33+
'log_level': 'debug'
3334
})
3435

3536
tts = c.get_traffic_types()
@@ -49,7 +50,8 @@ def test_environments_endpoint(self):
4950
'''
5051
c = get_client({
5152
'base_url': 'http://localhost:8888',
52-
'apikey': 'Admin'
53+
'apikey': 'Admin',
54+
'log_level': 'debug'
5355
})
5456

5557
envs = c.get_environments()
@@ -68,7 +70,8 @@ def test_attribute_endpoints(self):
6870
'''
6971
c = get_client({
7072
'base_url': 'http://localhost:8888',
71-
'apikey': 'Admin'
73+
'apikey': 'Admin',
74+
'log_level': 'debug'
7275
})
7376

7477
attrs = c.get_attributes_for_traffic_type('1')
@@ -81,6 +84,7 @@ def test_attribute_endpoints(self):
8184
'displayName': attr.display_name,
8285
'description': attr.description,
8386
'dataType': attr.data_type,
87+
'isSearchable': attr.is_searchable
8488
} == attr.to_dict()
8589
for attr in attrs
8690
)
@@ -90,15 +94,17 @@ def test_attribute_endpoints(self):
9094
'trafficTypeId': '1',
9195
'displayName': 'AA',
9296
'description': 'DESC',
93-
'dataType': 'STRING'
97+
'dataType': 'STRING',
98+
'isSearchable': False,
9499
}
95100
new_attr = c.create_attribute_for_traffic_type(
96101
'1',
97102
{
98103
'id': 'aa',
99104
'displayName': 'AA',
100105
'description': 'DESC',
101-
'dataType': 'STRING'
106+
'dataType': 'STRING',
107+
'isSearchable': False,
102108
}
103109
)
104110
assert new_attr_props == new_attr.to_dict()
@@ -111,7 +117,8 @@ def test_identity_endpoints(self):
111117
'''
112118
c = get_client({
113119
'base_url': 'http://localhost:8888',
114-
'apikey': 'Admin'
120+
'apikey': 'Admin',
121+
'log_level': 'debug'
115122
})
116123

117124
i1 = c.add_identity('1', '1', 'keycita', {'a1': 'qwe'})
@@ -149,16 +156,18 @@ def test_identity_endpoints(self):
149156
'key2': {'b1': 'c', 'c2': 'c'},
150157
}
151158
)
152-
assert isinstance(res_add_identities, list)
153-
assert all(isinstance(i, Identity) for i in res_add_identities)
159+
assert isinstance(res_add_identities, tuple)
160+
objs, failed = res_add_identities
161+
assert all(isinstance(i, Identity) for i in objs)
162+
assert all(isinstance(i['object'], Identity) for i in failed)
154163
assert all(
155164
{
156165
'key': i.key,
157166
'trafficTypeId': i.traffic_type_id,
158167
'environmentId': i.environment_id,
159168
'values': i.values,
160169
} == i.to_dict()
161-
for i in res_add_identities
170+
for i in objs
162171
)
163172

164173
res_delete_attr = c.delete_attributes_from_key('1', '1', 'keycita')

identify/tests/e2e/identify_backend/handlers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,13 @@ def delete(self, traffic_type_id, environment_id, key):
110110
class MultiIdentityHandler(BaseHandler):
111111
'''
112112
'''
113-
def put(self, traffic_type_id, environment_id):
113+
def post(self, traffic_type_id, environment_id):
114114
'''
115115
'''
116116
jbody = tornado.escape.json_decode(self.request.body)
117-
self.write(json.dumps(jbody))
117+
self.write(json.dumps({
118+
'objects': jbody,
119+
'failed': [],
120+
'metadata': {},
121+
}))
118122
self.finish()

identify/tests/e2e/identify_backend/responses.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,31 @@
2323
'trafficTypeId': '1',
2424
'displayName': 'Attribute 1a',
2525
'description': 'Description of attribute 1a',
26-
'dataType': 'string'
26+
'dataType': 'string',
27+
'isSearchable': False,
2728
}, {
2829
'id': '1b',
2930
'trafficTypeId': '1',
3031
'displayName': 'Attribute 1b',
3132
'description': 'Description of attribute 1b',
32-
'dataType': 'string'
33+
'dataType': 'string',
34+
'isSearchable': False,
3335
}
3436
],
3537
'2': [{
3638
'id': '2a',
3739
'trafficTypeId': '2',
3840
'displayName': 'Attribute 2a',
3941
'description': 'Description of attribute 2a',
40-
'dataType': 'string'
42+
'dataType': 'string',
43+
'isSearchable': False,
4144
}, {
4245
'id': '2b',
4346
'trafficTypeId': '2',
4447
'displayName': 'Attribute 2b',
4548
'description': 'Description of attribute 2b',
46-
'dataType': 'string'
49+
'dataType': 'string',
50+
'isSearchable': False,
4751
}
4852
]
4953
}

0 commit comments

Comments
 (0)