def test_boolean(self): input_val = 'true' expected_val = BooleanValue(True) actual_val = DataValueConverter.convert_to_data_value(input_val) self.assertEqual(expected_val, actual_val) input_val = 'false' expected_val = BooleanValue(False) actual_val = DataValueConverter.convert_to_data_value(input_val) self.assertEqual(expected_val, actual_val)
def test_integer(self): input_val = '10' expected_val = IntegerValue(10) actual_val = DataValueConverter.convert_to_data_value(input_val) self.assertEqual(expected_val, actual_val) input_val = '1000000000000000000000000000000' long_val = 1000000000000000000000000000000 expected_val = IntegerValue(long_val) actual_val = DataValueConverter.convert_to_data_value(input_val) self.assertEqual(expected_val, actual_val)
def test_list(self): input_val = '["val1","val2"]' expected_val = ListValue( values=[StringValue('val1'), StringValue('val2')]) actual_val = DataValueConverter.convert_to_data_value(input_val) self.assertEqual(expected_val, actual_val)
def test_dict(self): input_val = '{"int_field":10, "bool_field":true}' values = { 'bool_field': BooleanValue(True), 'int_field': IntegerValue(10) } expected_val = StructValue(values=values) actual_val = DataValueConverter.convert_to_data_value(input_val) self.assertEqual(expected_val, actual_val)
def test_none(self): input_val = 'null' expected_val = OptionalValue() actual_val = DataValueConverter.convert_to_data_value(input_val) self.assertEqual(expected_val, actual_val)
def test_empty_list(self): input_val = '[]' expected_val = ListValue() actual_val = DataValueConverter.convert_to_data_value(input_val) self.assertEqual(expected_val, actual_val)
def test_float(self): input_val = '1.01E1' expected_val = DoubleValue(decimal.Decimal('10.10')) actual_val = DataValueConverter.convert_to_data_value(input_val) self.assertEqual(expected_val, actual_val)
def test_unicode_string(self): input_val = '"val??"' expected_val = StringValue(u'val??') actual_val = DataValueConverter.convert_to_data_value(input_val) self.assertEqual(expected_val, actual_val)