def test_transfer_comparison():
    dict = {
        'trs_id': uuid.uuid4(),
        'trs_timestamp': '2019-01-21 09:00:00',
        'trs_from': acc1.to_dict(),
        'trs_to': acc2.to_dict(),
        'trs_amount': 100.00
    }
    trs1 = Transfer.from_dict(dict)
    trs2 = Transfer.from_dict(dict)

    assert trs1 == trs2
Exemple #2
0
    def list(self, filters=None):
        if not filters:
            result = self._entries
        else:
            result = []
            result.extend(self._entries)

            for key, value in filters.items():
                result = [
                    e for e in result if self._apply_filter(e, key, value)
                ]

        return [Transfer.from_dict(r) for r in result]
def test_transfer_from_dict():
    id = uuid.uuid4()
    dict = {
        'trs_id': id,
        'trs_timestamp': '2019-01-21 09:00:00',
        'trs_from': acc1.to_dict(),
        'trs_to': acc2.to_dict(),
        'trs_amount': 100.00
    }
    trs = Transfer.from_dict(dict)

    assert trs.trs_id == id
    assert trs.trs_timestamp == '2019-01-21 09:00:00'
    assert trs.trs_from == acc1
    assert trs.trs_to == acc2
    assert trs.trs_amount == 100.00
    }
transfer_dict3 = {
        'trs_id':str(uuid.uuid4()),
        'trs_timestamp':"2019-01-23 15:05:04",
        'trs_from':{'code':"5555555555E", 'balance': 1000},
        'trs_to':{'code':"7765432255B", 'balance': 1000},
        'trs_amount':400.00
    }
transfer_dict4 = {
        'trs_id':str(uuid.uuid4()),
        'trs_timestamp':"2019-01-24 14:00:59",
        'trs_from':{'code':"7777777777A", 'balance': 1000},
        'trs_to':{'code':"1111188888B", 'balance': 1000},
        'trs_amount':492.50
    }
trs1 = Transfer.from_dict(transfer_dict1)
trs2 = Transfer.from_dict(transfer_dict2)
trs3 = Transfer.from_dict(transfer_dict3)
trs4 = Transfer.from_dict(transfer_dict4)

test_transfers = [trs1, trs2, trs3, trs4]


@mock.patch('bankaccount.usecases.transfer_usecases.TransferHistoryUseCase')
def test_get_transfers(mock_usecase, client):
    mock_usecase().execute.return_value = resp.ResponseSuccess(test_transfers)
    http_response = client.get('/transfers')

    assert json.loads(http_response.data.decode('UTF-8')) == [transfer_dict1, transfer_dict2, 
                                                            transfer_dict3, transfer_dict4]
    assert http_response.status_code == 200