Exemple #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, "")
Exemple #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'))
Exemple #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,{})
Exemple #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")
Exemple #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()
Exemple #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)
Exemple #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)
Exemple #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))
Exemple #9
0
	def test_callRemotely_returnsText(self) :
		p = ServiceProxy("http://myhost:80")
		result = p.callRemotely("service")
		self.assertEqual(result, "Hola")
Exemple #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")