def test_authentication_header(self, pv_headers): pv_req = PicovicoRequest() assert not pv_req.is_authenticated() header = pv_headers.VALID.copy() header.update({'X-Access-Key': 'Valid'}) pv_req.headers = header assert not pv_req.is_authenticated() header.update({'X-Access-Token': None}) assert not pv_req.is_authenticated() header.update({'X-Access-Token': 'Valid', 'X-Access-Key': None}) assert not pv_req.is_authenticated() header.pop('X-Access-Token') header.update({'X-Access-Key': 'Valid'}) assert not pv_req.is_authenticated() pv_req.headers = pv_headers.AUTH.copy() assert pv_req.is_authenticated()
def test_properties(self, pv_headers, pv_urls): pv_request = PicovicoRequest() assert pv_request.headers is None pv_request = PicovicoRequest(pv_headers.VALID) assert pv_request.headers == pv_headers.VALID assert pv_request.url == pv_request.host pv_request.headers = {'additional': "this is nothing."} assert 'X-VALID' in pv_request.headers and 'additional' in pv_request.headers pv_request.url = urls.ME assert pv_request.url == pv_urls.ME