示例#1
0
 def testUploadEscapesDoubleQuotesInAboutValues(self):
     """
     Double quotes in about tag values are correctly escaped when converted
     to Fluidinfo queries.
     """
     fluidinfo = FakeFluidinfo()
     client = FluidinfoImporter(fluidinfo, 5)
     client.upload([{'about': '"hello world"', 'values': {'foo/bar': 13}}])
     body = {'queries': [[r'fluiddb/about = "\"hello world\""',
                          {'foo/bar': {'value': 13}}]]}
     self.assertEqual([(('PUT', '/values', body), {})], fluidinfo.calls)
示例#2
0
 def testUpload(self):
     """
     Object data is converted into a format compatible with the C{/values}
     API endoint and uploaded using the C{fluidinfo.py} client.
     """
     fluidinfo = FakeFluidinfo()
     client = FluidinfoImporter(fluidinfo, 5)
     client.upload([{'about': 'hello world', 'values': {'foo/bar': 13}}])
     body = {'queries': [['fluiddb/about = "hello world"',
                          {'foo/bar': {'value': 13}}]]}
     self.assertEqual([(('PUT', '/values', body), {})], fluidinfo.calls)
示例#3
0
 def testUploadMultipleObjects(self):
     """
     Objects are uploaded in batches when possible, depending on the batch
     size.
     """
     fluidinfo = FakeFluidinfo()
     client = FluidinfoImporter(fluidinfo, 2)
     client.upload([{'about': 'hello world', 'values': {'foo/bar': 13}},
                    {'about': 'wubble', 'values': {'baz/quux': 42}}])
     body = {'queries': [['fluiddb/about = "hello world"',
                          {'foo/bar': {'value': 13}}],
                         ['fluiddb/about = "wubble"',
                          {'baz/quux': {'value': 42}}]]}
     self.assertEqual([(('PUT', '/values', body), {})], fluidinfo.calls)
示例#4
0
 def testUploadLimitsByBatchSize(self):
     """
     Object data is split into batches, to control the number of objects
     that get added per request.
     """
     fluidinfo = FakeFluidinfo()
     client = FluidinfoImporter(fluidinfo, 1)
     client.upload([{'about': 'hello world', 'values': {'foo/bar': 13}}])
     client.upload([{'about': 'wubble', 'values': {'baz/quux': 42}}])
     body1 = {'queries': [['fluiddb/about = "hello world"',
                           {'foo/bar': {'value': 13}}]]}
     body2 = {'queries': [['fluiddb/about = "wubble"',
                           {'baz/quux': {'value': 42}}]]}
     self.assertEqual([(('PUT', '/values', body1), {}),
                       (('PUT', '/values', body2), {})], fluidinfo.calls)
示例#5
0
def main(args):
    """Run the Influx import tool.

    @param args: A C{list} of command-line arguments, typically C{sys.argv}.
    """
    options, args = parseOptions(args)
    client = getFluidinfoClient(options)
    importer = FluidinfoImporter(client, options.batchSize)
    logging.basicConfig(format='%(asctime)s %(levelname)8s  %(message)s',
                        level=logging.INFO)
    for path in args:
        with open(path, 'r') as file:
            data = load(file)
            logging.info('Uploading objects from %s' % path)
            importer.upload(data['objects'])
示例#6
0
 def testUploadEmptyDataset(self):
     """Uploading an empty dataset is a no-op."""
     fluidinfo = FakeFluidinfo()
     client = FluidinfoImporter(fluidinfo, 5)
     client.upload([])
     self.assertEqual([], fluidinfo.calls)