예제 #1
0
 def testImportSurvey(self):
     from plone.uuid.interfaces import IUUID
     snippet = objectify.fromstring(
         """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
          <title>Software development sector</title>
          <survey>
            <title>Software development</title>
          </survey>
        </sector>""")
     self.loginAsPortalOwner()
     country = self.portal.sectors.nl
     importer = upload.SectorImporter(country)
     importer(snippet, None, "login", None, u"Import")
     self.assertEqual(country.keys(),
                      ["help", "software-development-sector"])
     sector = country["software-development-sector"]
     self.assertEqual(sector.title, "Software development sector")
     self.assertEqual(sector.login, "login")
     self.failUnless(isinstance(sector.title, unicode))
     self.assertEqual(sector.keys(), ["software-development"])
     self.assertEqual(sector.contact_email, None)
     self.assertEqual(sector.password, None)
     group = sector["software-development"]
     self.assertEqual(group.title, "Software development")
     self.failUnless(isinstance(group.title, unicode))
     self.assertEqual(group.keys(), ["import"])
     self.assertTrue(isinstance(IUUID(sector), str))
예제 #2
0
def addSurvey(portal, xml_survey):
    """Add a survey to the portal. This function requires that you are already
    loggin in as portal owner."""
    from euphorie.content import upload
    from euphorie.client import publish
    importer = upload.SectorImporter(portal.sectors.nl)
    sector = importer(xml_survey, None, None, None, u"test import")
    survey = sector.values()[0]["test-import"]
    publisher = publish.PublishSurvey(survey, portal.REQUEST)
    publisher.publish()
예제 #3
0
 def testImportSurvey_WithAccount(self):
     snippet = objectify.fromstring(
         """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
          <title>Software development sector</title>
          <account login="******" password="******" />
          <contact>
            <name>Team lead</name>
            <email>[email protected]</email>
          </contact>
        </sector>""")
     self.loginAsPortalOwner()
     country = self.portal.sectors.nl
     importer = upload.SectorImporter(country)
     importer(snippet, None, None, None, u"Import")
     sector = country["software-development-sector"]
     self.assertEqual(sector.login, u"coders")
     self.assertEqual(sector.contact_name, u"Team lead")
     self.assertEqual(sector.contact_email, u"*****@*****.**")
     self.assertEqual(sector.password, "s3cr3t")
예제 #4
0
 def testImportSurvey_WithLogo(self):
     snippet = objectify.fromstring(
         """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
          <title>Software development sector</title>
          <logo filename="tiny.gif">R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAEALAAAAAABAAEAAAIBTAA7</logo>
        </sector>""")
     self.loginAsPortalOwner()
     country = self.portal.sectors.nl
     importer = upload.SectorImporter(country)
     importer(snippet, None, "login", None, u"Import")
     sector = country["software-development-sector"]
     self.assertNotEqual(sector.logo, None)
     self.assertEqual(sector.logo.filename, "tiny.gif")
     self.assertEqual(sector.logo.contentType, "image/gif")
     self.assertEqual(
         sector.logo.data, "GIF89a\x01\x00\x01\x00\x80\x00\x00"
         "\x00\x00\x00\xff\xff\xff!\xf9\x04"
         "\x01\x00\x00\x01\x00,\x00\x00\x00"
         "\x00\x01\x00\x01\x00\x00\x02\x01L"
         "\x00;")