def testConvertJsonDataFileWhenTypeChanges(self):
    infile = tempfile.NamedTemporaryFile(mode='rw+')
    outfile = tempfile.NamedTemporaryFile(mode='w+')
    json_before = '{"age": "22", "fullname": "John Doe"    }\n'
    # change: 22 is now an int.
    json_after = {'age': 22, 'fullname': 'John Doe'}
    infile.seek(0)
    infile.write(json_before)
    infile.seek(0)
    master_key = '%s' % _MASTER_KEY
    schema = [
        {
            'mode': 'nullable', 'name': 'age', 'type': 'integer',
            'encrypt': 'none'},
        {
            'mode': 'nullable', 'name': 'fullname', 'type': 'string',
            'encrypt': 'none'},
    ]
    table_id = '%s' % _TABLE_ID
    load_lib.ConvertJsonDataFile(
        schema, master_key, table_id, infile.name, outfile.name)
    # compare as dict because key order is flaky in str(dict)
    json_output = json.loads(outfile.read())
    self.assertEqual(json_output, json_after)
Test ConvertJsonDataFile().
dataset/ETHPy150Open google/encrypted-bigquery-client/src/load_lib_test.py/LoadLibraryTest.testConvertJsonDataFileWhenTypeChanges