def test_loader_json(): module = "User" name = 'test_loader_json_' + str(uuid.uuid4()).replace('-', '_') file_type = "json" f = tempfile.NamedTemporaryFile(delete=False, suffix='.json') f.write(""" [ { "a" : 1, "b" : 2, "c" : 3 }, { "a" : 4, "b" : 5, "c" : 6 } ] """) f.close() print "registering file %s" % f.name schema, properties = inferrer.from_local(name, f.name, file_type) metadata.register_shore_schema(user, module, name, schema) print properties, schema #assert(False) loader.load(user, module, name, f.name, file_type, properties, schema) os.remove(f.name)
def test_metadata(): module = "User" name = 'test_metadata_' + str(uuid.uuid4()).replace('-', '_') schema = rawListType(rawRecordType(name, OrderedDict([('field1', rawIntType()), ('field2', rawStringType())]))) print schema #assert(False) metadata.register_shore_schema(user, module, name, schema) assert(name in metadata.list_schemas(user, module))
def test_loader_csv(): module = "User" name = 'test_loader_csv_' + str(uuid.uuid4()).replace('-', '_') file_type = 'csv' f = tempfile.NamedTemporaryFile(delete=False, suffix='.csv') f.write("a,b\n") f.write("1,2\n") f.write("3,4\n") f.close() print "registering file %s" % f.name schema, properties = inferrer.from_local(name, f.name, file_type) metadata.register_shore_schema(user, module, name, schema) print properties, schema loader.load(user, module, name, f.name, file_type, properties, schema) os.remove(f.name)
def test_querycpp(): module = "User" name = 'test_querycpp_' + str(uuid.uuid4()).replace('-', '_') file_type = 'csv' f = tempfile.NamedTemporaryFile(delete=False, suffix='.csv') f.write("a,b\n") f.write("1,2\n") f.close() schema, properties = inferrer.from_local( name, f.name, file_type) metadata.register_shore_schema(user, module, name, schema) print properties, schema loader.load(user, module, name, f.name, file_type, properties, schema) result = querycpp.query(user, module, name) assert(result['compile_time'] > 0) assert(result['execution_time'] > 0)