コード例 #1
0
    def test_zip_positions_dates(self):
        unzipped = [("2020-12-22", 0), ("2020-12-23", 0), ("2020-12-24", 0)]
        expected = [(["2020-12-22", "2020-12-23", "2020-12-24"], [0])]

        result = zip_positions(unzipped)

        assert result == expected
コード例 #2
0
    def test_zip_empty(self):
        unzipped = []
        expected = []

        result = zip_positions(unzipped)

        assert result == expected
コード例 #3
0
    def test_zip_positions_empty(self):
        unzipped = [("2020-12-22", 0)]
        expected = [(["2020-12-22"], [0])]

        result = zip_positions(unzipped)

        assert result == expected
コード例 #4
0
    def test_zip_positions_less_than_5(self):
        unzipped = [
            ("2020-12-22", 0),
            ("2020-12-22", 1),
            ("2020-12-22", 2),
            ("2020-12-22", 3),
            ("2020-12-22", 4),
        ]
        expected = [(["2020-12-22"], [0, 1, 2, 3, 4])]

        result = zip_positions(unzipped)

        assert result == expected
コード例 #5
0
    def test_zip_positions_only_when_possible(self):
        unzipped = [
            ("2020-12-22", 0),
            ("2020-12-23", 0),
            ("2020-12-23", 1),
            ("2020-12-24", 0),
        ]
        expected = [
            (["2020-12-22"], [0]),
            (["2020-12-23"], [0, 1]),
            (["2020-12-24"], [0]),
        ]

        result = zip_positions(unzipped)

        assert result == expected
コード例 #6
0
    def make_pay_tx(self, target, amount, target_is_a_company=False):
        """Return Transaction to pay given target with given amount of Guzis

        Also add this Transaction to itself
        Return None and add no Transaction if amount == 0

        :returns: Unsigned Transaction or None
        """
        if amount < 0:
            raise NegativeAmountError
        if amount > self._get_available_guzis_amount():
            raise InsufficientFundsError
        guzis_positions = zip_positions(self._get_available_guzis()[:amount])
        return Transaction(
            VERSION,
            Transaction.PAYMENT,
            self.pubkey,
            amount,
            tx_date=datetime.date.today().isoformat(),
            target_user=target if not target_is_a_company else None,
            target_company=target if target_is_a_company else None,
            guzis_positions=guzis_positions,
        )