Пример #1
0
def test_cast_type_datetime_wrong_list_length():
    """
    Unit: tests cast_type when there's missing datetime metadata
          for the type cast.
    """
    with pytest.raises(BaseException):
        cast_type("10/08/1991", ["datetime"])
Пример #2
0
def test_cast_type_exception_unknown_drm_type():
    """
    Unit: tests cast_type when there's an unsupported or unknown type at the
          DRM yml file.
    """
    with pytest.raises(BaseException):
        cast_type("1234", "unknown_type")
Пример #3
0
def test_cast_type_value_exception():
    """
    Unit: tests cast_type when there's raised ValueError.
    """
    assert cast_type("123.144-5566/12345-6", "int") is None
Пример #4
0
def test_cast_type_metadata_unknown():
    """
    Unit: tests cast_type when the desired type is a list with unknown type.
    """
    with pytest.raises(BaseException):
        cast_type("10/08/1991", ["unknown_type", "whatever"])
Пример #5
0
def test_cast_type_datetime_no_timestamp():
    """
    Unit: tests cast_type when the datetime metadata contains no
          timestamp info.
    """
    assert cast_type("10/08/1991", ["datetime", "%d/%m/%Y %H:%M:%S"]) is None
Пример #6
0
def test_cast_type_datetime_type_ok():
    """
    Unit: tests cast_type when there's a correct cast to a datetime type.
    """
    assert (cast_type("10/08/1991",
                      ["datetime", "%d/%m/%Y"]) == "1991-08-10T00:00:00")
Пример #7
0
def test_cast_type_datetime_type_exception():
    """
    Unit: tests cast_type when there's an impossible cast to datetime.
    """
    assert cast_type("10/08/1991", ["datetime", "abc"]) is None
Пример #8
0
def test_cast_type_int_type():
    """
    Unit: tests cast_type when there's a correct cast to an int type.
    """
    assert cast_type("1234", "int") == 1234