def test_add_cls_none(self): client = FakeAPIClient('http://test.com') mapper = OsciedCRUDMapper(client, 'method') assert_raises(ValueError, mapper.add) assert_raises(ValueError, mapper.add, 10, arg=20) mapper.add('hello') mapper.add(arg1=0) assert_equal(client.do_request.call_args_list, [ call(post, u'http://test.com/method', data='"hello"'), call(post, u'http://test.com/method', data='{"arg1": 0}')])
def test_add_cls_user(self): client = FakeAPIClient('http://test.com') mapper = OsciedCRUDMapper(client, 'method', User, environment=True) user = User(first_name='Tabby', last_name='Fischer', mail='*****@*****.**', secret='mia0w_mia0w') user._id = '3959e400-94b0-49f7-8b0f-fd168b7c90e3' user.is_valid(True) mapper.add(user) assert_equal(client.do_request.call_args_list, [ call(post, u'http://test.com/method/environment/maas', data='{"first_name": "Tabby", "last_name": "Fischer", "admin_platform": false, "secret": "mia0w_mia0w"' ', "mail": "*****@*****.**", "_id": "3959e400-94b0-49f7-8b0f-fd168b7c90e3"}')])