Exemplo n.º 1
0
def test_basic_dict():
    output = print_type_to_string(Dict({'int_field': Field(Int)}))

    expected = '''{
  int_field: Int
}'''

    assert output == expected
Exemplo n.º 2
0
def test_optional_field():
    output = print_type_to_string(
        Dict({'int_field': Field(Int, is_optional=True)}))

    expected = '''{
  int_field?: Int
}'''

    assert output == expected
Exemplo n.º 3
0
def test_two_field_dicts_same_type():
    two_field_dict = Dict({'int_field1': Field(Int), 'int_field2': Field(Int)})
    assert_inner_types(two_field_dict, Int)

    output = print_type_to_string(two_field_dict)

    expected = '''{
  int_field1: Int
  int_field2: Int
}'''

    assert output == expected
Exemplo n.º 4
0
def test_optional_field():
    output = print_type_to_string(Dict({'int_field': Field(Int, is_optional=True)}))

    # print('OUTPUT')
    # print(output.replace(' ', '-'))
    # print('******')

    expected = '''{
  int_field?: Int
}'''

    assert output == expected
Exemplo n.º 5
0
def test_two_field_dicts():
    two_field_dict = Dict({'int_field': Field(Int), 'string_field': Field(String)})
    assert_inner_types(two_field_dict, Int, String)

    output = print_type_to_string(two_field_dict)

    expected = '''{
  int_field: Int
  string_field: String
}'''

    assert output == expected
Exemplo n.º 6
0
def test_basic_dict():
    output = print_type_to_string(Dict({'int_field': Field(Int)}))

    # print('OUTPUT')
    # print(output.replace(' ', '-'))
    # print('******')

    expected = '''{
  int_field: Int
}'''

    assert output == expected
Exemplo n.º 7
0
def test_nested_dict():
    nested_type = Dict({'int_field': Field(Int)})
    outer_type = Dict({'nested': Field(nested_type)})
    output = print_type_to_string(outer_type)

    assert_inner_types(outer_type, Int, nested_type)

    expected = '''{
  nested: {
    int_field: Int
  }
}'''

    assert output == expected
Exemplo n.º 8
0
def test_single_level_dict_lists_and_nullable():
    output = print_type_to_string(
        Dict({
            'nullable_int_field': Field(Nullable(Int)),
            'optional_int_field': Field(Int, is_optional=True),
            'string_list_field': Field(List(String)),
        }))

    expected = '''{
  nullable_int_field: Int?
  optional_int_field?: Int
  string_list_field: [String]
}'''

    assert output == expected
Exemplo n.º 9
0
def test_nullable_list_combos():
    assert print_type_to_string(List(Int)) == '[Int]'
    assert print_type_to_string(Nullable(List(Int))) == '[Int]?'
    assert print_type_to_string(List(Nullable(Int))) == '[Int?]'
    assert print_type_to_string(Nullable(List(Nullable(Int)))) == '[Int?]?'
Exemplo n.º 10
0
def test_basic_nullable_type_print():
    assert print_type_to_string(Nullable(Int)) == 'Int?'
    nullable_int = Nullable(Int)
    assert_inner_types(nullable_int, Int)
Exemplo n.º 11
0
def test_double_list_type_print():
    assert print_type_to_string(List(List(Int))) == '[[Int]]'
    int_list = List(Int)
    list_int_list = List(int_list)
    assert_inner_types(list_int_list, Int, int_list)
Exemplo n.º 12
0
def test_basic_list_type_print():
    assert print_type_to_string(List(Int)) == '[Int]'
    assert_inner_types(List(Int), Int)
Exemplo n.º 13
0
def test_basic_type_print():
    assert print_type_to_string(Int) == 'Int'
    assert_inner_types(Int)
Exemplo n.º 14
0
def test_nullable_list_combos():
    assert print_type_to_string(List[Int]) == '[Int]'
    assert print_type_to_string(Optional[List[Int]]) == '[Int]?'
    assert print_type_to_string(List[Optional[Int]]) == '[Int?]'
    assert print_type_to_string(Optional[List[Optional[Int]]]) == '[Int?]?'
Exemplo n.º 15
0
def test_basic_nullable_type_print():
    assert print_type_to_string(Optional[Int]) == 'Int?'
    nullable_int = Optional[Int]
    assert_inner_types(nullable_int, Int)
Exemplo n.º 16
0
def test_double_list_type_print():
    assert print_type_to_string(List[List[Int]]) == '[[Int]]'
    int_list = List[Int]
    list_int_list = List[int_list]
    assert_inner_types(list_int_list, Int, int_list)