diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7b5b817 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: python +python: + - "2.7" +# command to install dependencies +install: + - pip install -r requirements.txt +# command to run tests +script: + - python -m unittest discover -s ./tests -p 'px*' diff --git a/tests/px_proxy_handler.py b/tests/px_proxy_handler.py index c5e7bd9..92bce42 100644 --- a/tests/px_proxy_handler.py +++ b/tests/px_proxy_handler.py @@ -60,17 +60,13 @@ def test_send_reverse_captcha_request(self, mock): def test_send_reverse_xhr_request(self, mock): content = 'captcha content' config = PxConfig({'app_id': 'PXfake_app_id'}) - ctx = PxContext({'PATH_INFO': '/fake_app_id/init.js', + ctx = PxContext({'PATH_INFO': '/fake_app_id/xhr/api/v1/collector', 'HTTP_X_FORWARDED_FOR': '127.0.0.1', 'ip': '127.0.0.1'}, PxConfig({'app_id': 'fake_app_id'})) - ctx = {'uri': '/fake_app_id/xhr/api/v1/collector', - 'headers': {'X-FORWARDED-FOR': '127.0.0.1'}, - 'ip': '127.0.0.1', - 'REQUEST_METHOD': 'POST'} headers = {'host': config.collector_host, px_constants.FIRST_PARTY_HEADER: '1', - px_constants.ENFORCER_TRUE_IP_HEADER: ctx.get('ip'), + px_constants.ENFORCER_TRUE_IP_HEADER: ctx.ip, px_constants.FIRST_PARTY_FORWARDED_FOR: '127.0.0.1'} mock.post(url='https://collector-pxfake_app_id.perimeterx.net/api/v1/collector', text=content, request_headers=headers, status_code=200, reason='OK')