def testAddGetAnnotationValues(self):
     rodir = self.createTestRo(testbase, "data/ro-test-1", "Test get annotation values", "ro-testRoAnnotate")
     roresource = "subdir1/subdir1-file.txt"
     # Add anotations for file
     ro_annotation._addSimpleAnnotation(ro_config, rodir, roresource,
         "type",         "Test file")
     ro_annotation._addSimpleAnnotation(ro_config, rodir, roresource,
         "description",  "File in test research object")
     ro_annotation._addSimpleAnnotation(ro_config, rodir, roresource,
         "rdf:type",     ROTERMS.resource)
     # Retrieve the anotations
     values = ro_annotation._getAnnotationValues(ro_config, rodir, ".", "title")
     self.assertEquals(values.next(), rdflib.Literal('Test get annotation values'))
     self.assertRaises(StopIteration, values.next)
     values = ro_annotation._getAnnotationValues(ro_config, rodir, ".", "rdf:type")
     self.assertEquals(values.next(), RO.ResearchObject)
     self.assertRaises(StopIteration, values.next)
     values = ro_annotation._getAnnotationValues(ro_config, rodir, roresource, "type")
     self.assertEquals(values.next(), rdflib.Literal('Test file'))
     self.assertRaises(StopIteration, values.next)
     values = ro_annotation._getAnnotationValues(ro_config, rodir, roresource, "description")
     self.assertEquals(values.next(), rdflib.Literal('File in test research object'))
     self.assertRaises(StopIteration, values.next)
     values = ro_annotation._getAnnotationValues(ro_config, rodir, roresource, "rdf:type")
     self.assertEquals(values.next(), ROTERMS.resource)
     self.assertRaises(StopIteration, values.next)
     # Clean up
     self.deleteTestRo(rodir)
     return
    def testLink(self):
        """
        Annotate file in created RO

        ro annotate file attribute-name [ attribute-value ]
        """
        rodir = self.createTestRo(testbase, "data/ro-test-1", "RO test annotation", "ro-testRoAnnotate")
        args = [
            "ro", "annotate", rodir+"/"+"subdir1/subdir1-file.txt", "title", "subdir1-file title",
            "-v",
            ]
        with SwitchStdout(self.outstr):
            status = ro.runCommand(ro_test_config.CONFIGDIR, ro_test_config.ROBASEDIR, args)
        outtxt = self.outstr.getvalue()
        assert status == 0, outtxt
        log.debug("outtxt %s"%outtxt)
        #self.assertRegexpMatches(outtxt, "annotation.*dc:title")
        # Read manifest and check for annotation
        values = ro_annotation._getAnnotationValues(ro_config, rodir, "subdir1/subdir1-file.txt", "title")
        self.assertEquals(values.next(), rdflib.Literal("subdir1-file title"))
        self.assertRaises(StopIteration, values.next)
        # Clean up
        self.deleteTestRo(rodir)
        return