Пример #1
0
 def testGetFluidinfoClientWithDefaultSettings(self):
     """The main instance is used by default."""
     options, args = parseOptions(['-u', 'user', '-p', 'secret', 'path'])
     client = getFluidinfoClient(options)
     self.assertEqual('https://fluiddb.fluidinfo.com', client.instance)
     self.assertEqual('Basic dXNlcjpzZWNyZXQ=',
                      client.global_headers['Authorization'])
Пример #2
0
 def testParseOptionsUsesSensibleDefaultValues(self):
     """Sensible defaults are provided for all options."""
     options, args = parseOptions(['-u', 'user', '-p', 'secret', 'path'])
     self.assertEqual(100, options.batchSize)
     self.assertEqual('https://fluiddb.fluidinfo.com', options.endpoint)
     self.assertFalse(options.verbose)
     self.assertEqual(['path'], args)
Пример #3
0
 def testParseOptions(self):
     """Command-line arguments override default values."""
     options, args = parseOptions(['-u', 'user', '-p', 'secret', '-b', '7',
                                   '-e', 'http://localhost:9000', 'path'])
     self.assertEqual('user', options.username)
     self.assertEqual('secret', options.password)
     self.assertEqual(7, options.batchSize)
     self.assertEqual('http://localhost:9000', options.endpoint)
     self.assertEqual(['path'], args)
Пример #4
0
 def testGetFluidinfoClientWithCustomSettings(self):
     """
     The API endpoint can be configured by passing a command-line argument.
     """
     options, args = parseOptions(['-u', 'user', '-p', 'secret',
                                   '-e', 'http://localhost:9000', 'path'])
     client = getFluidinfoClient(options)
     self.assertEqual('http://localhost:9000', client.instance)
     self.assertEqual('Basic dXNlcjpzZWNyZXQ=',
                      client.global_headers['Authorization'])
Пример #5
0
 def testGetFluidinfoClientWithVerboseFlag(self):
     """Debugging is enabled in C{httplib2} when the verbose flag is set."""
     originalDebugLevel = httplib2.debuglevel
     try:
         options, args = parseOptions(['-u', 'user', '-p', 'secret',
                                       '-e', 'http://localhost:9000', '-v',
                                       'path'])
         getFluidinfoClient(options)
         self.assertEqual(1, httplib2.debuglevel)
     finally:
         httplib2.debuglevel = originalDebugLevel
Пример #6
0
 def testParseOptionsWithVerboseFlag(self):
     """An optional C{-v} flag can be provided to enable verbose logging."""
     options, args = parseOptions(['-u', 'user', '-p', 'secret', '-v',
                                   'path'])
     self.assertTrue(options.verbose)