Exemple #1
0
 def test_urchin(self):
     """
     When an Urchin API key is present, the code for enabling Google
     Analytics tracking should be inserted into the shell template.
     """
     keyString = u"UA-99018-11"
     APIKey.setKeyForAPI(self.siteStore, APIKey.URCHIN, keyString)
     page = self.createPage(None)
     t = div()
     result = page.render_urchin(context.WebContext(tag=t), None)
     self.assertEqual(result.slotData["urchin-key"], keyString)
Exemple #2
0
 def test_urchin(self):
     """
     When an Urchin API key is present, the code for enabling Google
     Analytics tracking should be inserted into the shell template.
     """
     keyString = u"UA-99018-11"
     APIKey.setKeyForAPI(self.siteStore, APIKey.URCHIN, keyString)
     page = self.createPage(None)
     t = div()
     result = page.render_urchin(context.WebContext(tag=t), None)
     self.assertEqual(result.slotData['urchin-key'], keyString)
Exemple #3
0
    def postOptions(self):
        siteStore = self.parent.getStore()

        # Make sure the base mantissa offering is installed.
        offeringTech = ixmantissa.IOfferingTechnician(siteStore)
        offerings = offeringTech.getInstalledOfferingNames()
        if baseOffering.name not in offerings:
            raise UsageError(
                "This command can only be used on Mantissa databases.")

        # It is, we can make some simplifying assumptions.  Specifically,
        # there is exactly one SiteConfiguration installed.
        site = siteStore.findUnique(SiteConfiguration)

        if self['http-log'] is not None:
            if self['http-log']:
                site.httpLog = siteStore.filesdir.preauthChild(
                    self['http-log'])
            else:
                site.httpLog = None

        if self['hostname'] is not None:
            if self['hostname']:
                site.hostname = self.decodeCommandLine(self['hostname'])
            else:
                raise UsageError("Hostname may not be empty.")

        if self['urchin-key'] is not None:
            # Install the API key for Google Analytics, to enable tracking for
            # this site.
            APIKey.setKeyForAPI(
                siteStore, APIKey.URCHIN, self['urchin-key'].decode('ascii'))


        # Set up whatever static content was requested.
        for webPath, filePath in self.staticPaths:
            staticSite = siteStore.findFirst(
                StaticSite, StaticSite.prefixURL == webPath)
            if staticSite is not None:
                staticSite.staticContentPath = filePath
            else:
                staticSite = StaticSite(
                    store=siteStore,
                    staticContentPath=filePath,
                    prefixURL=webPath,
                    sessionless=True)
                onlyInstallPowerups(staticSite, siteStore)
Exemple #4
0
 def test_setKeyForAPINew(self):
     """
     If there is no existing key for the named API, L{APIKey.setKeyForAPI}
     should create a new L{APIKey} item.
     """
     theAPIKey = u'this is an API key.'
     theAPIName = u'this is an API name.'
     apiKey = APIKey.setKeyForAPI(self.store, theAPIName, theAPIKey)
     self.assertIdentical(apiKey, self.store.findUnique(APIKey))
     self.assertEqual(theAPIKey, apiKey.apiKey)
     self.assertEqual(theAPIName, apiKey.apiName)
Exemple #5
0
 def test_setKeyForAPINew(self):
     """
     If there is no existing key for the named API, L{APIKey.setKeyForAPI}
     should create a new L{APIKey} item.
     """
     theAPIKey = u'this is an API key.'
     theAPIName = u'this is an API name.'
     apiKey = APIKey.setKeyForAPI(
         self.store, theAPIName, theAPIKey)
     self.assertIdentical(apiKey, self.store.findUnique(APIKey))
     self.assertEqual(theAPIKey, apiKey.apiKey)
     self.assertEqual(theAPIName, apiKey.apiName)
Exemple #6
0
 def test_setKeyForAPIExisting(self):
     """
     If there is an existing for the named API, L{APIKey.setKeyForAPI}
     should update its I{apiKey} attribute.
     """
     theAPIKey = u'this is an API key.'
     theAPIName = u'this is an API name.'
     existingAPIKey = APIKey(store=self.store,
                             apiName=theAPIName,
                             apiKey=theAPIKey)
     newAPIKey = u'this is a new API key'
     returnedAPIKey = APIKey.setKeyForAPI(self.store, theAPIName, newAPIKey)
     self.assertIdentical(existingAPIKey, returnedAPIKey)
     self.assertEqual(existingAPIKey.apiName, theAPIName)
     self.assertEqual(existingAPIKey.apiKey, newAPIKey)
Exemple #7
0
 def test_setKeyForAPIExisting(self):
     """
     If there is an existing for the named API, L{APIKey.setKeyForAPI}
     should update its I{apiKey} attribute.
     """
     theAPIKey = u'this is an API key.'
     theAPIName = u'this is an API name.'
     existingAPIKey = APIKey(
         store=self.store, apiName=theAPIName, apiKey=theAPIKey)
     newAPIKey = u'this is a new API key'
     returnedAPIKey = APIKey.setKeyForAPI(
         self.store, theAPIName, newAPIKey)
     self.assertIdentical(existingAPIKey, returnedAPIKey)
     self.assertEqual(existingAPIKey.apiName, theAPIName)
     self.assertEqual(existingAPIKey.apiKey, newAPIKey)