コード例 #1
0
ファイル: test_oscied_api.py プロジェクト: codecwatch/OSCIED
 def test_get_url_with_environment(self):
     client = FakeAPIClient('http://test.com')
     mapper = OsciedCRUDMapper(client, id_prefix='id', environment=True)
     assert_equal(mapper.get_url(), u'http://test.com/environment/maas')
     assert_equal(mapper.get_url(extra='extra_value'), u'http://test.com/environment/maas/extra_value')
     assert_equal(mapper.get_url(index='index_value'), u'http://test.com/environment/maas/id/index_value')
     assert_equal(mapper.get_url(index='index_value', extra='extra_value'),
                  u'http://test.com/environment/maas/id/index_value/extra_value')
コード例 #2
0
ファイル: test_oscied_api.py プロジェクト: codecwatch/OSCIED
 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}')])
コード例 #3
0
ファイル: test_oscied_api.py プロジェクト: codecwatch/OSCIED
 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"}')])