def test_shortOptionParsing(self): """ Test that the short form of all the supported command line options are parsed correctly. """ opt = webcmd.WebConfiguration() opt.parent = self certFile = self.store.filesdir.child('name') opt.parseOptions(['-h', 'http.log', '-H', 'example.com']) self.assertEquals(opt['http-log'], 'http.log') self.assertEquals(opt['hostname'], 'example.com')
def test_staticParsing(self): """ Test that the --static option parses arguments of the form "url:filename" correctly. """ opt = webcmd.WebConfiguration() opt.parent = self opt.parseOptions( ['--static', 'foo:bar', '--static', 'quux/fooble:/bar/baz']) self.assertEquals(opt.staticPaths, [('foo', os.path.abspath('bar')), ('quux/fooble', '/bar/baz')])
def test_urchinKey(self): """ Specifying a Google Analytics key inserts an item into the database recording it. """ opt = webcmd.WebConfiguration() opt.parent = self opt['urchin-key'] = 'A123' opt.postOptions() self.assertEquals( APIKey.getKeyForAPI(self.store, APIKey.URCHIN).apiKey, u'A123')
def test_hostname(self): """ The I{hostname} option changes the C{hostname} attribute of the L{SiteConfiguration} object installed on the store. The hostname cannot be set to the empty string. """ opt = webcmd.WebConfiguration() opt.parent = self opt['hostname'] = 'example.com' opt.postOptions() opt['hostname'] = '' self.assertRaises(UsageError, opt.postOptions) self.assertEqual( self.store.findUnique(SiteConfiguration).hostname, u"example.com")
def _list(self): wconf = webcmd.WebConfiguration() wconf.parent = self wout = _captureStandardOutput(wconf.parseOptions, ['--list']) return wout
def setUp(self): self.store = Store() self.options = webcmd.WebConfiguration() self.options.parent = self