Esempio n. 1
0
	def test_callRemotely_badHost(self) :
		p = ServiceProxy("http://badhost:80")
		try :
			p.callRemotely("service")
			self.fail("Exception expected")
		except urllib2.URLError as e :
			self.assertEqual(e.message, "")
Esempio n. 2
0
	def test_callRemotely_withArg(self) :
		p = ServiceProxy("http://myhost:80")
		p.callRemotely("service", a="boo")

		self.assertEqual(self.query.path,'/service')
		self.assertEqual(self.query.method,'POST')
		self.assertEqual(self.params,dict(a='boo'))
Esempio n. 3
0
	def test_callRemotely_noArgs(self) :
		p = ServiceProxy("http://myhost:80")
		p.callRemotely("service")

		self.assertEqual(self.query.path,'/service')
		self.assertEqual(self.query.method,'POST')
		self.assertEqual(self.query.params,{})
Esempio n. 4
0
	def test_callRemotely_internalError(self) :
		p = ServiceProxy("http://myhost:80")
		try :
			p.callRemotely("service", error="Message")
			self.fail("Exception expected")
		except RemoteError as e :
			self.assertEqual(e.message, "Message")
Esempio n. 5
0
async def master_socket_handler(loop, master_socket):
    while True:
        sock, _ = await loop.sock_accept(master_socket)

        try:
            ServiceProxy(sock, service_type, target, loop)
        except ConnectionRefusedError as e:
            logger.warning("%s: %s", e, target)
            sock.close()
Esempio n. 6
0
	def test_callRemotely_internalError(self) :
		p = ServiceProxy("http://myhost:80")
		try :
			p.callRemotely("service", error="Message")
			self.fail("Exception expected")
		except urllib2.HTTPError as e :
			self.assertEqual(e.reason, "Internal Server Error")
			self.assertEqual(e.read(), "Message")
			self.assertEqual(e.getcode(), 500)
Esempio n. 7
0
	def test_callRemotely_notFoundError(self) :
		p = ServiceProxy("http://myhost")
		try :
			p.callRemotely("service", notfound="Message")
			self.fail("Exception expected")
		except urllib2.HTTPError as e :
			self.assertEqual(e.reason, "Not found")
			self.assertEqual(e.read(), "Message")
			self.assertEqual(e.getcode(), 404)
Esempio n. 8
0
	def test_callRemotely_withIntArgs(self) :
		p = ServiceProxy("http://myhost:80")
		p.callRemotely("service", a=1)

		self.assertEqual(self.query.path,'/service')
		self.assertEqual(self.params,dict(a=1))
Esempio n. 9
0
	def test_callRemotely_returnsText(self) :
		p = ServiceProxy("http://myhost:80")
		result = p.callRemotely("service")
		self.assertEqual(result, "Hola")
Esempio n. 10
0
	def test_callRemotely_anouncesAsUserAgent(self) :
		p = ServiceProxy("http://myhost:80")
		p.callRemotely("service")

		self.assertEqual(self.query.user_agent,
			"python-service-proxy/1.0")