Exemplo n.º 1
0
class TestClientMixin(HopliteClientTestCase):
    def setUp(self):
        self.mixin = ClientMixin()

    def test_jget(self):
        with HTTMock(get):
            r = self.mixin.jget("http://localhost:5001/test")
            self.assertOk(r)

    def test_jpost(self):
        with HTTMock(post):
            r = self.mixin.jpost("http://localhost:5001/test", data=DATA)
            self.assertOk(r)

    def test_jput(self):
        with HTTMock(put):
            r = self.mixin.jput("http://localhost:5001/test", data=DATA)
            self.assertOk(r)

    def test_jpatch(self):
        with HTTMock(patch):
            r = self.mixin.jpatch("http://localhost:5001/test", data=DATA)
            self.assertOk(r)

    def test_jdelete(self):
        with HTTMock(delete):
            r = self.mixin.jdelete("http://localhost:5001/test", data=DATA)
            self.assertOk(r)

    def raises_on_500_status_code(self):
        with HTTMock(return_500):
            self.assertRaises(InternalServerError, self.mixin.jget("localhost"))
            self.assertRaises(InternalServerError, self.mixin.jpost("localhost"))
            self.assertRaises(InternalServerError, self.mixin.jput("localhost"))
            self.assertRaises(InternalServerError, self.mixin.jpatch("localhost"))
            self.assertRaises(InternalServerError, self.mixin.jdelete("localhost"))
Exemplo n.º 2
0
 def setUp(self):
     self.mixin = ClientMixin()