def test_http_exception_404(self): service = DALService('http://example.com/query/nonexistant') try: service.search() except DALServiceError as exc: assert exc.code == 404 else: assert False
def test_http_exception_500(self): service = DALService('http://example.com/query/errornous') try: service.search() except DALServiceError as exc: assert exc.code == 500 else: assert False
def test_search(self): """ Test (in conjunction with mocker) that parameters arrive serverside, while also ensuring data consistency """ service = DALService('http://example.com/query/verbosetest') dalresults = service.search(VERBOSE=1) _test_results(dalresults) _test_records(dalresults)
def test_format_exception(self): with pytest.raises(DALFormatError): service = DALService('http://example.com/query/missingtable') service.search() with pytest.raises(DALFormatError): service = DALService('http://example.com/query/missingresource') service.search() with pytest.raises(DALFormatError): service = DALService('http://example.com/query/missingcolumns') service.search()
def test_query_exception(self): service = DALService('http://example.com/query/errorstatus') with pytest.raises(DALQueryError): service.search()
def test_useragent(self): service = DALService('http://example.com/query/useragent') service.search()
def test_init(self): """Test if baseurl if passed correctly""" service = DALService('http://example.com/query/basic') assert service.baseurl == 'http://example.com/query/basic'