Beispiel #1
0
    def test_opencor_link(self):
        context = self.layer['portal'].unrestrictedTraverse(
            self.layer['exposure_file1_path'])
        request = TestRequest(
            form={
                'form.widgets.annotators': [u'opencor'],
                'form.buttons.apply': 1,
            })
        view = ExposureFileAnnotatorForm(context, request)
        view.update()  # should succeed.

        note = zope.component.queryAdapter(context, name='opencor')
        note.filename = 'README'

        urltool = zope.component.queryAdapter(
            context, IExposureNoteTarget, name='opencor')
        url = urltool('opencor')
        self.assertEqual(url,
            'opencor://openFile/http://nohost/plone/workspace/rdfmodel/rawfile'
            '/2/README')

        # Not really needed any longer, but kept here for completness.
        view = zope.component.queryMultiAdapter(
            (context, self.layer['portal'].REQUEST), name='opencor')
        view.__call__()
        self.assertEqual(
            view.request.response.headers,
            {'location':
                'http://nohost/plone/workspace/rdfmodel/@@rawfile/2/README'}
        )
Beispiel #2
0
 def test_base_codegen(self):
     context = self.layer["portal"].unrestrictedTraverse(self.layer["exposure_file1_path"])
     request = TestRequest(form={"form.widgets.annotators": [u"cellml_codegen"], "form.buttons.apply": 1})
     view = ExposureFileAnnotatorForm(context, request)
     view.update()
     note = zope.component.getAdapter(context, name="cellml_codegen")
     langkeys = note.code.keys()
     self.assertIn("C", langkeys)
     self.assertIn("F77", langkeys)
     self.assertIn("MATLAB", langkeys)
     self.assertIn("Python", langkeys)
Beispiel #3
0
    def test_exposure_rdf_annotation(self):
        gs = zope.component.getUtility(IPMR2GlobalSettings)
        settings = zope.component.getAdapter(gs, name='pmr2_virtuoso')
        engine = zope.component.getAdapter(settings, IEngine)
        engine._clear()

        self.assertEqual(len(engine.stmts), 0)

        exposure = self.layer['portal'].virtuoso_exposure.virtuoso_test
        context = exposure['simple.rdf']
        request = TestRequest(form={
            'form.widgets.annotators': [u'virtuoso_rdf'],
            'form.buttons.apply': 1,
        })
        view = ExposureFileAnnotatorForm(context, request)
        view.update()

        # this should have indexed.
        self.assertEqual(len(engine.stmts), 2)

        engine._clear()
        # follow up with post annotation
        request = TestRequest(form={
            'form.widgets.exclude_nav': 1,
            'form.buttons.apply': 1,
        })
        annotator = zope.component.getUtility(IExposureFileAnnotator,
            name='virtuoso_rdf')(context, request)
        annotator(data=(('exclude_nav', 1),))

        note = zope.component.getAdapter(context, name='virtuoso_rdf')

        self.assertEqual(len(engine.stmts), 2)
        self.assertEqual(engine.stmts[0], 'SPARQL '
            'CLEAR GRAPH <urn:pmr:virtuoso:/plone/'
                'virtuoso_exposure/virtuoso_test/simple.rdf>')

        self.assertTrue(context.getExcludeFromNav())

        annotator = zope.component.getUtility(IExposureFileAnnotator,
            name='virtuoso_rdf')(context, request)
        annotator(data=(('exclude_nav', 0),))
        self.assertFalse(context.getExcludeFromNav())
Beispiel #4
0
    def test_exposure_rdf_annotation_data_optional(self):
        # data is actually optionally provided sometimes due to how
        # there is only one field.
        gs = zope.component.getUtility(IPMR2GlobalSettings)
        settings = zope.component.getAdapter(gs, name='pmr2_virtuoso')
        engine = zope.component.getAdapter(settings, IEngine)
        engine._clear()

        self.assertEqual(len(engine.stmts), 0)

        exposure = self.layer['portal'].virtuoso_exposure.virtuoso_test
        context = exposure['simple.rdf']
        request = TestRequest(form={
            'form.widgets.annotators': [u'virtuoso_rdf'],
            'form.buttons.apply': 1,
        })
        view = ExposureFileAnnotatorForm(context, request)
        view.update()

        engine._clear()

        # follow up with post annotation
        request = TestRequest(form={
            'form.widgets.exclude_nav': 1,
            'form.buttons.apply': 1,
        })
        annotator = zope.component.getUtility(IExposureFileAnnotator,
            name='virtuoso_rdf')(context, request)
        # again, this has provided no data.
        annotator(data=())

        note = zope.component.getAdapter(context, name='virtuoso_rdf')

        self.assertEqual(len(engine.stmts), 2)
        self.assertEqual(engine.stmts[0], 'SPARQL '
            'CLEAR GRAPH <urn:pmr:virtuoso:/plone/'
                'virtuoso_exposure/virtuoso_test/simple.rdf>')