コード例 #1
0
def test_nullserial():
    """Test a failed serial verification based on argument not being passed in.

    :return: True
    """
    with pytest.raises(
            TypeError,
            match="missing 1 required positional argument: 'serial'"):
        verify_serial()
コード例 #2
0
def test_nonstringserial():
    """Test a failed serial verification based on argument not being passed in.

    :return: True
    """
    serial = 4
    with pytest.raises(AttributeError,
                       match="Serial number must be a string."):
        verify_serial(serial)
コード例 #3
0
def test_emptyserial():
    """Test a failed serial verification based on length being 0.

    :return: True
    """
    serial = ""
    with pytest.raises(
            AttributeError,
            match="Serial number must contain at least the last 4 characters.",
    ):
        verify_serial(serial)
コード例 #4
0
def test_longserial():
    """Test a failed serial verification based on length being longer than
    12 characters.

    :return: True
    """
    serial = "C02LR3KJRNRTI"
    with pytest.raises(
            AttributeError,
            match="Serial number contains more than 12 characters."):
        verify_serial(serial)