def test_basic_map_type_print(): assert (print_config_type_to_string({str: int}) == """{ [String]: Int }""") assert_inner_types({str: int}, int, str) assert (print_config_type_to_string({int: int}) == """{ [Int]: Int }""") assert_inner_types({int: int}, int, int)
def test_map_name_print(): assert (print_config_type_to_string(Map(str, int, key_label_name="name")) == """{ [name: String]: Int }""") assert (print_config_type_to_string(Map(int, float, key_label_name="title")) == """{ [title: Int]: Float }""")
def test_optional_field(): output = print_config_type_to_string({'int_field': Field(int, is_required=False)}) expected = '''{ int_field?: Int }''' assert output == expected
def test_basic_dict(): output = print_config_type_to_string({'int_field': int}) expected = '''{ int_field: Int }''' assert output == expected
def test_basic_dict(): output = print_config_type_to_string({"int_field": int}) expected = """{ int_field: Int }""" assert output == expected
def test_optional_field(): output = print_config_type_to_string( {"int_field": Field(int, is_required=False)}) expected = """{ int_field?: Int }""" assert output == expected
def test_nested_dicts_and_maps(): output = print_config_type_to_string( {"field_one": { str: { "field_two": { str: int } } }}) expected = """{
def test_double_map_type_print(): assert (print_config_type_to_string({str: { str: int }}) == """{ [String]: { [String]: Int } }""") int_map = {str: int} map_int_map = {str: int_map} assert_inner_types(map_int_map, Int, int_map, String)
def test_two_field_dicts(): two_field_dict = {"int_field": int, "string_field": str} assert_inner_types(two_field_dict, Int, String) output = print_config_type_to_string(two_field_dict) expected = """{ int_field: Int string_field: String }""" assert output == expected
def test_two_field_dicts_same_type(): two_field_dict = {"int_field1": int, "int_field2": int} assert_inner_types(two_field_dict, Int) output = print_config_type_to_string(two_field_dict) expected = """{ int_field1: Int int_field2: Int }""" assert output == expected
def test_two_field_dicts_same_type(): two_field_dict = {'int_field1': int, 'int_field2': int} assert_inner_types(two_field_dict, Int) output = print_config_type_to_string(two_field_dict) expected = '''{ int_field1: Int int_field2: Int }''' assert output == expected
def test_two_field_dicts(): two_field_dict = {'int_field': int, 'string_field': str} assert_inner_types(two_field_dict, Int, String) output = print_config_type_to_string(two_field_dict) expected = '''{ int_field: Int string_field: String }''' assert output == expected
def test_nested_dict(): nested_type = {'int_field': int} outer_type = {'nested': nested_type} output = print_config_type_to_string(outer_type) assert_inner_types(outer_type, Int, nested_type) expected = '''{ nested: { int_field: Int } }''' assert output == expected
def test_nested_dict(): nested_type = {"int_field": int} outer_type = {"nested": nested_type} output = print_config_type_to_string(outer_type) assert_inner_types(outer_type, Int, nested_type) expected = """{ nested: { int_field: Int } }""" assert output == expected
def test_single_level_dict_lists_and_nullable(): output = print_config_type_to_string({ "nullable_int_field": Noneable(int), "optional_int_field": Field(int, is_required=False), "string_list_field": [str], }) expected = """{ nullable_int_field: Int? optional_int_field?: Int string_list_field: [String] }""" assert output == expected
def test_single_level_dict_lists_and_nullable(): output = print_config_type_to_string( { 'nullable_int_field': Noneable(int), 'optional_int_field': Field(int, is_required=False), 'string_list_field': [str], } ) expected = '''{ nullable_int_field: Int? optional_int_field?: Int string_list_field: [String] }''' assert output == expected
def test_list_map_nullable_combos(): # Don't care about newlines here for brevity's sake, those are tested elsewhere assert print_config_type_to_string( {str: [int]}, with_lines=False) == "{ [String]: [Int] }" assert (print_config_type_to_string( Noneable({str: [int]}), with_lines=False) == "{ [String]: [Int] }?") assert (print_config_type_to_string( {str: Noneable([int])}, with_lines=False) == "{ [String]: [Int]? }") assert (print_config_type_to_string( {str: [Noneable(int)]}, with_lines=False) == "{ [String]: [Int?] }") assert (print_config_type_to_string( Noneable({str: [Noneable(int)]}), with_lines=False) == "{ [String]: [Int?] }?") assert (print_config_type_to_string( Noneable({str: Noneable([Noneable(int)])}), with_lines=False) == "{ [String]: [Int?]? }?")
def test_basic_type_print(): assert print_config_type_to_string(Int) == "Int" assert_inner_types(Int)
def test_basic_list_type_print(): assert print_config_type_to_string([int]) == "[Int]" assert_inner_types([int], Int)
def test_nullable_list_combos(): assert print_config_type_to_string([int]) == "[Int]" assert print_config_type_to_string(Noneable([int])) == "[Int]?" assert print_config_type_to_string([Noneable(int)]) == "[Int?]" assert print_config_type_to_string(Noneable([Noneable(int)])) == "[Int?]?"
def test_basic_nullable_type_print(): assert print_config_type_to_string(Noneable(int)) == "Int?" nullable_int = Noneable(int) assert_inner_types(nullable_int, Int)
def test_double_list_type_print(): assert print_config_type_to_string([[int]]) == "[[Int]]" int_list = [int] list_int_list = [int_list] assert_inner_types(list_int_list, Int, int_list)