lczub / TestLink-API-Python-client

A Python client to use the TestLink API
104 stars 63 forks source link

proxiedtransport's send_request method is missing a parameter #127

Closed seanmlyons22 closed 4 years ago

seanmlyons22 commented 4 years ago

As of the xmlrpc version in Python version 3.7.6 the send_request method of class Transport that is overridden by proxiedtransport.py::send_request is missing the debug parameter.

Steps to reproduce

  1. Use Python 3.7.6
  2. Have http_proxy and https_proxy set as environment variables
  3. Call getProjects for example
  4. observe exception with traceback that ends in :

    http_conn = self.send_request(host, handler, request_body, verbose)
    TypeError: send_request() takes 4 positional arguments but 5 were given
seanmlyons22 commented 4 years ago

Another issue is that xmlrpc has specifies the first agrument as the host and not a connection handle. So this would need to be updated.

lczub commented 4 years ago

Hello Sean,

thanks for your request. Unfortunately, I have problems to reproduce your issue. To be honest, I'm not very familiar with the transport and proxie stuff.

We have within testlinkhelper_test.py some pytests to check the setup of the connection with proxie, but none testing the communication itself. Maybe that is the gap, cause the existing tests passed with 3.7.4, 3.7.6 and 3.8.1.

To solve your problem, I need a little more infos

That would be very helpful, Regards Luiko

seanmlyons22 commented 4 years ago

Hi @lczub ,

I wanted to apologize for taking so long to get back to you (the github notification email was lost in my inbox so I didn't see your reply).

Here is the traceback:

[testlinkclient] <update_structure()>
Traceback (most recent call last):
  File "C:\Users\a0225155\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\a0225155\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "c:\git\slate\slate\__main__.py", line 8, in <module>
    main()
  File "c:\git\slate\slate\main.py", line 347, in main
    app(args)
  File "c:\git\slate\slate\main.py", line 206, in app
    testlink.main(args.no_upload_skipped)
  File "c:\git\slate\slate\testlink\testlink.py", line 29, in main
    tl_client.update_structure(report)
  File "C:\git\slate\.slate\lib\site-packages\testlinkclient\testlinkclient.py", line 120, in update_structure
    self.tls.getTestProjectByName(self.project)
  File "C:\git\slate\.slate\lib\site-packages\testlink\testlinkdecorators.py", line 112, in wrapperAddDevKey
    return methodAPI(self, *argsPositional, **argsOptional)
  File "C:\git\slate\.slate\lib\site-packages\testlink\testlinkdecorators.py", line 100, in wrapperWithArgs
    *argsPositional, **argsOptional)
  File "C:\git\slate\.slate\lib\site-packages\testlink\testlinkapigeneric.py", line 1517, in callServerWithPosArgs
    response = self._callServer(methodNameAPI, argsOptional)
  File "C:\git\slate\.slate\lib\site-packages\testlink\testlinkapigeneric.py", line 1992, in _callServer
    response = getattr(self.server.tl, methodNameAPI)(argsAPI)
  File "C:\Users\a0225155\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "C:\Users\a0225155\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1452, in __request
    verbose=self.__verbose
  File "C:\Users\a0225155\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1154, in request
    return self.single_request(host, handler, request_body, verbose)
  File "C:\Users\a0225155\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1166, in single_request
    http_conn = self.send_request(host, handler, request_body, verbose)
TypeError: send_request() takes 4 positional arguments but 5 were given

Note that testlinkclient.py is a layer we have built above the TestLinkAPI package. I'm happy to try and reproduce with a vanilla test or example from the repo. Do you have some instructions on what I should try?

lczub commented 4 years ago

Hello Sean,

thanks for your traceback. A workaround for you might be to directly change the problematic overridden send_request method and add an optional debug argument in src/testlink/proxiedtransport.py

    #def send_request(self, connection, handler, request_body):
    def send_request(self, connection, handler, request_body, debug=False):

The hole content of src/testlink/proxiedtransport.py looks as it is a copy&paste of the py27 xmlrpclib.Transport behavior. It is from 2015 pull request #36 and as you mention, Py3 has changed in the meantime, so it requires a general rework.

This will take a while, because I will first try to set up a proxy test environment to understand, how proxy transport works.

Hope, that above workaround will not direct you to a different hidden P3 proxy isssue. Hope this helps a little bit. Stay healthy! Luiko

hellboy81 commented 4 years ago

Hi. I have another question.

Why in xmlrpc\client.py

def send_request(self, host, handler, request_body, debug):

and in overridden method from class ProxiedTransport (testlink\proxiedtransport.py)

def send_request(self, connection, handler, request_body, debug=False)

connection as first parameter defined?

After fixing problem with debug parameter I still have problem with connection.

image

This bug can be fixed as follows:

    def send_request(self, host, handler, request_body, debug=False):
        """Send request header

        :param httplib.HTTPConnection connection: Connection handle
        :param str handler: Target RPC handler
        :param str request_body:XML-RPC body
        """

        connection = super().send_request(host, handler, request_body, debug)

Can u also check this code? If it works - can I make pull request?

lczub commented 4 years ago

Hello Hellboy,

thanks for your good questions and suggestions. my problem is, I have currently no proxy test environment.

My impression during the code inspection for https://github.com/lczub/TestLink-API-Python-client/issues/127#issuecomment-613473372 was, that most parts of the overwritten code parts from #36 might be not really necessary any more. But I can not test it currently and haven't found time to rework it. I hope I can do it during teh next weekend.

Luiko

lczub commented 4 years ago

Hello seanmlyons22 and hellboy81,

I published I first draft for the proxiedtransport refactoring which should support py27 and py37/py38 on Branch dev127-proxietransport.

It is just tested with simple pytests and not a real proxy test environment

You find the related changed files in commit 891b041. If you could run a test with your proxy environment would be very helpful.

Regards Luiko