[PATCH 2 of 3 saem_ref] [test] Update oai test to follow changes in 0.4.2

Sylvain Thenault sylvain.thenault at logilab.fr
Wed Mar 22 10:57:27 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1490112879 -3600
#      Tue Mar 21 17:14:39 2017 +0100
# Node ID dd9ff0df5d055d5d2d62669b7595ea4e89c8cef7
# Parent  4ba8b2fffa85e8006b75758a4dddfa62d31a331d
[test] Update oai test to follow changes in 0.4.2

There is still one failure though, to be discussed.

diff --git a/test/test_oai.py b/test/test_oai.py
--- a/test/test_oai.py
+++ b/test/test_oai.py
@@ -22,10 +22,11 @@ import time
 from dateutil.parser import parse as parse_date
 from lxml import etree
 import pytz
 
 from cubicweb.devtools.testlib import CubicWebTC
+from cubicweb.pyramid.test import PyramidCWTest
 
 from cubes.oaipmh.views import OAIError, OAIRequest
 
 from cubicweb_saem_ref import permanent_url
 
@@ -154,21 +155,31 @@ def no_validate_xml(method):
         self._debug_xml = True
         return method(self)
     return wrapper
 
 
-class OAIPMHViewsTC(CubicWebTC, OAITestMixin, testutils.XmlTestMixin):
+class OAIPMHViewsTC(PyramidCWTest, OAITestMixin, testutils.XmlTestMixin):
+    settings = {
+        # to get clean traceback in tests (instead of in an html error page)
+        'cubicweb.bwcompat': False,
+        # avoid noise in test output (UserWarning: !! WARNING WARNING !! you
+        # should stop this instance)
+        'cubicweb.session.secret': 'x',
+        'cubicweb.auth.authtkt.session.secret': 'x',
+        'cubicweb.auth.authtkt.persistent.secret': 'x',
+    }
 
     _validate_xml = True
     _debug_xml = False
 
     def oai_request(self, req, **formparams):
-        req.form.update(formparams)
-        out = self.app_handle_request(req, 'oai')
+        response = self.webapp.get('/oai', formparams)
+        self.assertEqual(response.headers['Content-Type'], 'text/xml; charset=UTF-8')
         if self._validate_xml:
-            self.assertXmlValid(out, self.datapath('OAI-PMH.xsd'), debug=self._debug_xml)
-        return out
+            self.assertXmlValid(response.body, self.datapath('OAI-PMH.xsd'),
+                                debug=self._debug_xml)
+        return response.body
 
     def _setup_organization_units(self, **kwargs):
         with self.admin_access.repo_cnx() as cnx:
             return setup_organization_units(cnx, **kwargs)
 


More information about the saem-devel mailing list