コード例 #1
0
def test_sub_underflow():
    try:
        Currency(5) - Currency(7)
        raise Exception("no underflow")
    except CurrencyUnderflow:
        pass
    except:
        raise
コード例 #2
0
    def test_send_payment(self, mock_post, snapshot):
        mock_post.return_value = self._mock_response(json_data={"data": "foo"})

        client = Client()
        currency = Currency(1)
        fee = Currency(0.1)
        client.send_payment(to_pk="to_pk",
                            from_pk="from_pk",
                            amount=currency,
                            fee=fee,
                            memo="memo")
        snapshot.assert_match(mock_post.call_args_list)
コード例 #3
0
    def test_set_current_snark_worker(self, mock_post, snapshot):
        mock_post.return_value = self._mock_response(json_data={"data": "foo"})

        client = Client()
        fee = Currency(1)
        client.set_current_snark_worker("pk", fee=fee)
        snapshot.assert_match(mock_post.call_args_list)
コード例 #4
0
def test_random():
    assert Currency.random(Currency(5),
                           Currency(5)).nanominas() == 5 * precision
    for _ in range(25):
        rand = Currency.random(
            Currency(3, format=CurrencyFormat.NANO),
            Currency(5, format=CurrencyFormat.NANO),
        )
        assert 3 <= rand.nanominas() and rand.nanominas() <= 5
コード例 #5
0
def test_constructor_whole_int():
    n = 500
    assert Currency(n).nanominas() == n * precision
コード例 #6
0
def test_mul_currency():
    assert (
        Currency(5) *
        Currency(2, format=CurrencyFormat.NANO)).nanominas() == 10 * precision
コード例 #7
0
def test_mul_int():
    assert (Currency(5) * 2).nanominas() == 10 * precision
コード例 #8
0
def test_sub():
    assert (Currency(5) - Currency(2)).nanominas() == 3 * precision
コード例 #9
0
def test_add():
    assert (Currency(5) + Currency(2)).nanominas() == 7 * precision
コード例 #10
0
def test_constructor_nano_int():
    n = 500
    assert Currency(n, format=CurrencyFormat.NANO)
コード例 #11
0
def test_constructor_whole_string():
    n = "5.5"
    assert Currency(n).nanominas() == float(n) * precision
コード例 #12
0
def test_constructor_whole_float():
    n = 5.5
    assert Currency(n).nanominas() == n * precision