async def test_save_nothing(self): acct = MyUpdateable.construct_from({ 'id': 'myid', 'metadata': { 'key': 'value', } }, 'mykey') self.assertTrue(acct is await acct.save()) self.requestor_mock.request.assert_not_called()
async def test_array_noop(self): acct = MyUpdateable.construct_from({ 'id': 'myid', 'legal_entity': { 'additional_owners': [{'first_name': 'Bob'}] }, 'currencies_supported': ['usd', 'cad'] }, 'mykey') self.assertTrue(acct is await acct.save()) self.requestor_mock.request.assert_called_with('post', '/v1/myupdateables/myid', { 'legal_entity': {'additional_owners': {'0': {}}} }, None)
async def test_hash_noop(self): acct = MyUpdateable.construct_from({ 'id': 'myid', 'legal_entity': { 'address': {'line1': '1 Two Three'} } }, 'mykey') self.assertTrue(acct is await acct.save()) self.requestor_mock.request.assert_called_with('post', '/v1/myupdateables/myid', { 'legal_entity': { 'address': {} } }, None)
def setUp(self): super().setUp() self.mock_response({ 'thats': 'it' }) self.obj = MyUpdateable.construct_from({ 'id': 'myid', 'foo': 'bar', 'baz': 'boz', 'metadata': { 'size': 'l', 'score': 4, 'height': 10 } }, 'mykey')
async def test_array_none(self): acct = MyUpdateable.construct_from({ 'id': 'myid', 'legal_entity': { 'additional_owners': None, } }, 'mykey') acct.foo = 'bar' self.assertTrue(acct is await acct.save()) self.requestor_mock.request.assert_called_with('post', '/v1/myupdateables/myid', { 'foo': 'bar', 'legal_entity': {}, }, None)
async def test_array_setting(self): acct = MyUpdateable.construct_from({ 'id': 'myid', 'legal_entity': {} }, 'mykey') acct.legal_entity.additional_owners = [{'first_name': 'Bob'}] self.assertTrue(acct is await acct.save()) self.requestor_mock.request.assert_called_with('post', '/v1/myupdateables/myid', { 'legal_entity': { 'additional_owners': [ {'first_name': 'Bob'} ] } }, None)
async def test_add_key_to_nested_object(self): acct = MyUpdateable.construct_from({ 'id': 'myid', 'legal_entity': { 'size': 'l', 'score': 4, 'height': 10 } }, 'mykey') acct.legal_entity['first_name'] = 'bob' self.assertTrue(acct is await acct.save()) self.requestor_mock.request.assert_called_with('post', '/v1/myupdateables/myid', { 'legal_entity': { 'first_name': 'bob', } }, None)
async def test_replace_nested_object(self): acct = MyUpdateable.construct_from({ 'id': 'myid', 'legal_entity': { 'last_name': 'smith', } }, 'mykey') acct.legal_entity = { 'first_name': 'bob', } self.assertTrue(acct is await acct.save()) self.requestor_mock.request.assert_called_with('post', '/v1/myupdateables/myid', { 'legal_entity': { 'first_name': 'bob', 'last_name': '', } }, None)