Skip to content

Commit cafe048

Browse files
Merge pull request #1 from janrain/topic/schemarecord-fixes
Topic/schemarecord fixes
2 parents 8d1b020 + b02aedc commit cafe048

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

janrain_datalib/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""Package version"""
2-
__version__ = '0.1.1'
2+
__version__ = '0.1.2'

janrain_datalib/schemarecord.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def as_dict(self, attributes=None):
5151
kwargs = {
5252
'type_name': self.schema_name,
5353
'key_attribute': self.id_attribute,
54-
'key_value': self.id_value,
54+
# must be a "JSON" string
55+
'key_value': '"{}"'.format(self.id_value),
5556
}
5657
if attributes is not None:
5758
kwargs['attributes'] = attributes
@@ -71,7 +72,8 @@ def validate_password(self, password, password_attribute='password'):
7172
kwargs = {
7273
'type_name': self.schema_name,
7374
'key_attribute': self.id_attribute,
74-
'key_value': self.id_value,
75+
# must be a "JSON" string
76+
'key_value': '"{}"'.format(self.id_value),
7577
'password_attribute': password_attribute,
7678
'password_value': password,
7779
'attributes': [self.id_attribute],
@@ -98,6 +100,8 @@ def create(self, attributes):
98100
'attributes': attributes,
99101
}
100102
r = self.app.apicall('entity.create', **kwargs)
103+
self._id_attribute = 'uuid'
104+
self._id_value = r['uuid']
101105

102106
return {
103107
'id': r['id'],
@@ -109,7 +113,8 @@ def delete(self):
109113
kwargs = {
110114
'type_name': self.schema_name,
111115
'key_attribute': self.id_attribute,
112-
'key_value': self.id_value,
116+
# must be a "JSON" string
117+
'key_value': '"{}"'.format(self.id_value),
113118
}
114119
self.app.apicall('entity.delete', **kwargs)
115120

@@ -125,7 +130,8 @@ def replace(self, attributes, attribute_path=None):
125130
kwargs = {
126131
'type_name': self.schema_name,
127132
'key_attribute': self.id_attribute,
128-
'key_value': self.id_value,
133+
# must be a "JSON" string
134+
'key_value': '"{}"'.format(self.id_value),
129135
'attributes': attributes,
130136
}
131137
if attribute_path is not None:
@@ -142,7 +148,8 @@ def update(self, attributes, attribute_path=None):
142148
kwargs = {
143149
'type_name': self.schema_name,
144150
'key_attribute': self.id_attribute,
145-
'key_value': self.id_value,
151+
# must be a "JSON" string
152+
'key_value': '"{}"'.format(self.id_value),
146153
'attributes': attributes,
147154
}
148155
if attribute_path is not None:

tests/test_schemarecord.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_as_dict(self):
2727
self.assertEqual(record, self.mockapi.entities[0])
2828

2929
calls = [
30-
mock.call('entity', type_name=self.schema_name, key_attribute='uuid', key_value=self.uuid)
30+
mock.call('entity', type_name=self.schema_name, key_attribute='uuid', key_value='"{}"'.format(self.uuid))
3131
]
3232
self.assertEqual(calls, self.mockapi.call.mock_calls)
3333

@@ -47,7 +47,7 @@ def test_delete(self):
4747
self.record.delete()
4848

4949
calls = [
50-
mock.call('entity.delete', type_name=self.schema_name, key_attribute='uuid', key_value=self.uuid)
50+
mock.call('entity.delete', type_name=self.schema_name, key_attribute='uuid', key_value='"{}"'.format(self.uuid))
5151
]
5252
self.assertEqual(calls, self.mockapi.call.mock_calls)
5353

@@ -58,7 +58,7 @@ def test_replace(self):
5858
self.record.replace(attr)
5959

6060
calls = [
61-
mock.call('entity.replace', type_name=self.schema_name, key_attribute='uuid', key_value=self.uuid, attributes=attr)
61+
mock.call('entity.replace', type_name=self.schema_name, key_attribute='uuid', key_value='"{}"'.format(self.uuid), attributes=attr)
6262
]
6363
self.assertEqual(calls, self.mockapi.call.mock_calls)
6464

@@ -69,7 +69,7 @@ def test_update(self):
6969
self.record.update(attr)
7070

7171
calls = [
72-
mock.call('entity.update', type_name=self.schema_name, key_attribute='uuid', key_value=self.uuid, attributes=attr)
72+
mock.call('entity.update', type_name=self.schema_name, key_attribute='uuid', key_value='"{}"'.format(self.uuid), attributes=attr)
7373
]
7474
self.assertEqual(calls, self.mockapi.call.mock_calls)
7575

0 commit comments

Comments
 (0)