Example #1
0
	def __init__(self, param={}):
		self.conf = {
			'url':'http://zthf'+'tech.eic'+'p.net:180/',
			'encoding':'utf-8',
			'image_base':'R:/',
			'action_login':string.Template('portal/workflow/login.wf'),
			'action_login_referer':'portal/index_blue.jsp',
			'action_msglist':string.Template('portal/workflow/login.wf?sid=$sid&cmd=Navigation_Frame_Main&systemId=21'),
			'action_msglist_referer':string.Template('portal/workflow/login.wf?sid=$sid&cmd=Navigation_Frame_Top&systemId=21'),
			'action_msglist2':string.Template('portal/workflow/login.wf?sid=$sid&cmd=Portal_Execute_MessageWorkFlowTransaction&PORTLET_PARAM_SYSTEM_UUID=$uuid&PORTLET_PARAM_SYSTEM_UUID=$uuid'),
			'action_message':'portal/workflow/message.wf',
			'action_message_detail':'portal/workflow/message.wf?sid=$sid&cmd=WorkFlow_Execute_Worklist_BindReport_Open&id=$id&openstate=$openstate&task_id=$task_id',
			'action_govword':'portal/workflow/govWord.wf',
			
			'action_post':string.Template('post.php?action=newthread&fid=$fid&extra=page%3D1&topicsubmit=yes'),
			'action_seccode':string.Template('ajax.php?action=updateseccode&inajax=1'),
		}
		self.conf.update(param)
		#
		HttpClient.__init__(self, self.conf['url'], '')
		self.opener.addheaders=[('Accept-Language','zh-cn'), \
			('User-agent','Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1))')]
		self.url = self.conf['url']
		self.encoding = self.conf['encoding']
		self.image_base = self.conf['image_base']
		self.formhash = ''
Example #2
0
    def test_http_operations(self, http_mock):
        conn = mock.MagicMock()
        http_mock.return_value = conn

        http_client = HttpClient("localhost", 12345)
        url = "method1"
        params = {"data": {"a": "val1"}}

        # Verify post
        http_client.post(url, params)
        http_mock.assert_called_with("localhost", 12345)
        body = json.dumps(params["data"])
        conn.request.assert_called_with("POST", url, body, self.headers)
        # Verify put
        http_client.put(url, params)
        conn.request.assert_called_with("PUT", url, body, self.headers)
        # Verify patch
        http_client.patch(url, params)
        conn.request.assert_called_with("PATCH", url, body, self.headers)
        # Verify get
        http_client.get(url, params)
        conn.request.assert_called_with("GET", url, body, self.headers)
Example #3
0
    def test_http_operations(self, http_mock):
        conn = mock.MagicMock()
        http_mock.return_value = conn

        http_client = HttpClient("localhost", 12345)
        url = "method1"
        params = {"data": {"a": "val1"}}

        # Verify post
        http_client.post(url, params)
        http_mock.assert_called_with("localhost", 12345)
        body = json.dumps(params["data"])
        conn.request.assert_called_with("POST", url, body, self.headers)
        # Verify put
        http_client.put(url, params)
        conn.request.assert_called_with("PUT", url, body, self.headers)
        # Verify patch
        http_client.patch(url, params)
        conn.request.assert_called_with("PATCH", url, body, self.headers)
        # Verify get
        http_client.get(url, params)
        conn.request.assert_called_with("GET", url, body, self.headers)
Example #4
0
	def __init__(self):
		conf = self.conf
		HttpClient.__init__(self, conf['url'], conf['username'])