def test_as_str_invalid(): amount = UTXOAmounts(VALID_ADDR_1, "1:100:2:332") amount.data = [10, 11, 12, 5, 13, 6] with pytest.raises(TypeError): amount.as_str() amount.data = ['10', '11', '12', '5', '13', '6'] val = amount.as_str() assert val == '10:11:12:5:13:6'
def test_as_str(): amount = UTXOAmounts(VALID_ADDR_1, "1:100:2:332") str_val = amount.as_str() assert str_val == "1:100:2:332" amount = UTXOAmounts(VALID_ADDR_1, "1:100:2:332") amount.data = ["1", "100", "2"] with pytest.raises(UTXOError): amount.as_str()
def test_add_amount(): amount = UTXOAmounts(VALID_ADDR_1, "1:100") amount.add_amount(3, 23) assert len(amount.data) == 4 assert amount.data[2] == "3" assert amount.data[3] == "23" assert amount.as_str() == "1:100:3:23" amount = UTXOAmounts(VALID_ADDR_1, "1:100:2:332") amount.add_amount(3, 23) assert len(amount.data) == 6 assert amount.data[4] == "3" assert amount.data[5] == "23" assert amount.as_str() == "1:100:2:332:3:23" with pytest.raises(UTXOError): amount = UTXOAmounts(VALID_ADDR_1, "1:100") amount.add_amount(None, 32) amount.add_amount(32, None)