Adapt response.content for RDF and xhtml validator
authorDiane Trout <diane@ghic.org>
Wed, 14 Sep 2016 23:59:12 +0000 (16:59 -0700)
committerDiane Trout <diane@ghic.org>
Wed, 14 Sep 2016 23:59:12 +0000 (16:59 -0700)
Irritatingly one wants bytes and one wants unicode under python3.

experiments/test_experiments.py
samples/test_samples.py

index c89d7d479176c9a3003cd0992a2959862ff22ad4..253b5f7be6a1095777785c282803401e71bfec77 100644 (file)
@@ -13,7 +13,7 @@ from django.core import mail
 from django.core.exceptions import ObjectDoesNotExist
 from django.core.urlresolvers import reverse
 from django.test import TestCase
-from django.utils.encoding import smart_text
+from django.utils.encoding import smart_text, smart_bytes
 
 from .models import SequencingRun, Sequencer, FlowCell, FileType
 from samples.models import HTSUser
@@ -605,13 +605,12 @@ class TestSequencer(TestCase):
 
         url = '/lane/{}'.format(self.lane.id)
         response = self.client.get(url)
-        rdfbody = smart_text(response.content)
         self.assertEqual(response.status_code, 200)
-        status = validate_xhtml(rdfbody)
+        status = validate_xhtml(smart_bytes(response.content))
         if status is not None:
             self.assertTrue(status)
 
-        load_string_into_model(model, 'rdfa', rdfbody)
+        load_string_into_model(model, 'rdfa', smart_text(response.content))
 
         errmsgs = list(inference.run_validation())
         self.assertEqual(len(errmsgs), 0)
index 7acae97c8cb802336f49146d292e12e490e1a956..537e9cb2f94b1c2cd975de3c0d7c489dceea20ed 100644 (file)
@@ -6,7 +6,7 @@ from unittest import skipUnless
 
 from django.core.exceptions import ValidationError
 from django.test import TestCase, RequestFactory
-from django.utils.encoding import smart_text, smart_str
+from django.utils.encoding import smart_text, smart_str, smart_bytes
 
 from .models import Affiliation, ExperimentType, Species, Library
 from .views import library_dict
@@ -211,8 +211,7 @@ class SampleWebTestCase(TestCase):
 
         response = self.client.get(library.get_absolute_url())
         self.assertEqual(response.status_code, 200)
-        content = smart_text(response.content)
-        load_string_into_model(model, 'rdfa', content)
+        load_string_into_model(model, 'rdfa', smart_text(response.content))
 
         body = """prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
         prefix libns: <http://jumpgate.caltech.edu/wiki/LibraryOntology#>
@@ -236,7 +235,7 @@ class SampleWebTestCase(TestCase):
             self.assertEqual(fromTypedNode(r['made_by']),
                              library.made_by)
 
-        state = validate_xhtml(content)
+        state = validate_xhtml(smart_bytes(response.content))
         if state is not None:
             self.assertTrue(state)