コード例 #1
0
ファイル: test_core.py プロジェクト: agargiulo/python-github3
 def setUp(self):
     self.s = Service()
     self.r = DummyRequest()
     self.args = dict(arg1='arg1', arg2='arg2')
コード例 #2
0
ファイル: test_core.py プロジェクト: ad-m/python-github3
 def setUp(self):
     self.s = Service()
     self.r = DummyRequest()
     self.args = dict(arg1="arg1", arg2="arg2")
コード例 #3
0
ファイル: test_core.py プロジェクト: agargiulo/python-github3
class TestServiceCalls(TestCase):

    def setUp(self):
        self.s = Service()
        self.r = DummyRequest()
        self.args = dict(arg1='arg1', arg2='arg2')

    def test_BOOL(self, request_method):
        self.s._bool(self.r, **self.args)
        request_method.assert_called_with('head', _('dummyrequest'),
                                          params=self.args)

    def test_PUT(self, request_method):
        self.s._put(self.r, **self.args)
        data = ''  # See _put
        request_method.assert_called_with('put', _('dummyrequest'),
                                          data=data, params=self.args)

    def test_DELETE(self, request_method):
        request_method.return_value = mock_response('delete')
        self.s._delete(self.r, **self.args)
        request_method.assert_called_with('delete', _('dummyrequest'),
                                          data=None, params=self.args)

    def test_POST(self, request_method):
        request_method.return_value = mock_response('post')
        self.s._post(self.r, **self.args)
        request_method.assert_called_with('post', _('dummyrequest'),
                                          data=None, params=self.args)

    def test_GET(self, request_method):
        request_method.return_value = mock_response()
        self.s._get(self.r, **self.args)
        request_method.assert_called_with('get', _('dummyrequest'),
                                          params=self.args)

    def test_GET_result(self, request_method):
        result = self.s._get_result(self.r, **self.args)
        self.assertFalse(request_method.called)
        self.assertIsInstance(result, base.Result)
コード例 #4
0
ファイル: test_core.py プロジェクト: ad-m/python-github3
class TestServiceCalls(TestCase):
    def setUp(self):
        self.s = Service()
        self.r = DummyRequest()
        self.args = dict(arg1="arg1", arg2="arg2")

    def test_BOOL(self, request_method):
        self.s._bool(self.r, **self.args)
        request_method.assert_called_with("head", _("dummyrequest"), params=self.args)

    def test_PUT(self, request_method):
        self.s._put(self.r, **self.args)
        data = "PLACEHOLDER"  # See _put
        request_method.assert_called_with("put", _("dummyrequest"), data=data, params=self.args)

    def test_DELETE(self, request_method):
        request_method.return_value = mock_response("delete")
        self.s._delete(self.r, **self.args)
        request_method.assert_called_with("delete", _("dummyrequest"), data=None, params=self.args)

    def test_POST(self, request_method):
        request_method.return_value = mock_response("post")
        self.s._post(self.r, **self.args)
        request_method.assert_called_with("post", _("dummyrequest"), data=None, params=self.args)

    def test_GET(self, request_method):
        request_method.return_value = mock_response()
        self.s._get(self.r, **self.args)
        request_method.assert_called_with("get", _("dummyrequest"), params=self.args)

    def test_GET_result(self, request_method):
        result = self.s._get_result(self.r, **self.args)
        self.assertFalse(request_method.called)
        self.assertIsInstance(result, base.Result)
コード例 #5
0
ファイル: test_core.py プロジェクト: KWMalik/python-github3
class TestServiceCalls(TestCase):

    def setUp(self):
        self.s = Service()
        self.r = DummyRequest()
        self.args = dict(arg1='arg1', arg2='arg2')

    def test_BOOL(self, request_method):
        self.s._bool(self.r, **self.args)
        request_method.assert_called_with('head', _('dummyrequest'),
                                          params=self.args)

    def test_PUT(self, request_method):
        self.s._put(self.r, **self.args)
        data = 'PLACEHOLDER'  # See _put
        request_method.assert_called_with('put', _('dummyrequest'),
                                          data=data, params=self.args)

    def test_DELETE(self, request_method):
        request_method.return_value = mock_response('delete')
        self.s._delete(self.r, **self.args)
        request_method.assert_called_with('delete', _('dummyrequest'),
                                          data=None, params=self.args)

    def test_POST(self, request_method):
        request_method.return_value = mock_response('post')
        self.s._post(self.r, **self.args)
        request_method.assert_called_with('post', _('dummyrequest'),
                                          data=None, params=self.args)

    def test_GET(self, request_method):
        request_method.return_value = mock_response()
        self.s._get(self.r, **self.args)
        request_method.assert_called_with('get', _('dummyrequest'),
                                          params=self.args)

    def test_GET_result(self, request_method):
        result = self.s._get_result(self.r, **self.args)
        self.assertFalse(request_method.called)
        self.assertIsInstance(result, base.Result)

    def test_normalize_ok(self, request_method):
        data = {'test': datetime(2012, 12, 12, 3, 3, 3)}
        self.s._normalize_date('test', data)
        self.assertEqual(data['test'], '2012-12-12T03:03:03Z')

    def test_normalize_fail(self, request_method):
        data = {'test': 'fail'}
        self.s._normalize_date('test', data)
        self.assertEqual(data['test'], 'fail')
コード例 #6
0
 def setUp(self):
     self.s = Service()
     self.r = DummyRequest()
     self.args = dict(arg1='arg1', arg2='arg2')
コード例 #7
0
class TestServiceCalls(TestCase):
    def setUp(self):
        self.s = Service()
        self.r = DummyRequest()
        self.args = dict(arg1='arg1', arg2='arg2')

    def test_BOOL(self, request_method):
        self.s._bool(self.r, **self.args)
        request_method.assert_called_with('head',
                                          _('dummyrequest'),
                                          params=self.args)

    def test_PUT(self, request_method):
        self.s._put(self.r, **self.args)
        data = 'PLACEHOLDER'  # See _put
        request_method.assert_called_with('put',
                                          _('dummyrequest'),
                                          data=data,
                                          params=self.args)

    def test_DELETE(self, request_method):
        request_method.return_value = mock_response('delete')
        self.s._delete(self.r, **self.args)
        request_method.assert_called_with('delete',
                                          _('dummyrequest'),
                                          data=None,
                                          params=self.args)

    def test_POST(self, request_method):
        request_method.return_value = mock_response('post')
        self.s._post(self.r, **self.args)
        request_method.assert_called_with('post',
                                          _('dummyrequest'),
                                          data=None,
                                          params=self.args)

    def test_GET(self, request_method):
        request_method.return_value = mock_response()
        self.s._get(self.r, **self.args)
        request_method.assert_called_with('get',
                                          _('dummyrequest'),
                                          params=self.args)

    def test_GET_result(self, request_method):
        result = self.s._get_result(self.r, **self.args)
        self.assertFalse(request_method.called)
        self.assertIsInstance(result, base.Result)
コード例 #8
0
class TestServiceCalls(TestCase):
    def setUp(self):
        self.s = Service()
        self.r = DummyRequest()
        self.args = dict(arg1='arg1', arg2='arg2')

    def test_BOOL(self, request_method):
        self.s._bool(self.r, **self.args)
        request_method.assert_called_with('head',
                                          _('dummyrequest'),
                                          params=self.args)

    def test_PUT(self, request_method):
        self.s._put(self.r, **self.args)
        data = 'PLACEHOLDER'  # See _put
        request_method.assert_called_with('put',
                                          _('dummyrequest'),
                                          data=data,
                                          params=self.args)

    def test_DELETE(self, request_method):
        request_method.return_value = mock_response('delete')
        self.s._delete(self.r, **self.args)
        request_method.assert_called_with('delete',
                                          _('dummyrequest'),
                                          data=None,
                                          params=self.args)

    def test_POST(self, request_method):
        request_method.return_value = mock_response('post')
        self.s._post(self.r, **self.args)
        request_method.assert_called_with('post',
                                          _('dummyrequest'),
                                          data=None,
                                          params=self.args)

    def test_GET(self, request_method):
        request_method.return_value = mock_response()
        self.s._get(self.r, **self.args)
        request_method.assert_called_with('get',
                                          _('dummyrequest'),
                                          params=self.args)

    def test_GET_result(self, request_method):
        result = self.s._get_result(self.r, **self.args)
        self.assertFalse(request_method.called)
        self.assertIsInstance(result, base.Result)

    def test_normalize_ok(self, request_method):
        data = {'test': datetime(2012, 12, 12, 3, 3, 3)}
        self.s._normalize_date('test', data)
        self.assertEqual(data['test'], '2012-12-12T03:03:03Z')

    def test_normalize_fail(self, request_method):
        data = {'test': 'fail'}
        self.s._normalize_date('test', data)
        self.assertEqual(data['test'], 'fail')