<filename>tests/test_path_and_order.py
from tests import BaseTestClass


class TestPathAndOrderBook(BaseTestClass):
    def test_book_offers(self):
        test_taker_account = '<KEY>'
        test_issuer_account = '<KEY>'
        get_currency = 'XRP'
        pay_currency = 'USD'
        info = self.rpc.book_offers(taker=test_taker_account, issuer=test_issuer_account,
                                    taker_gets_currency=get_currency, taker_pays_currency=pay_currency)
        self.assertIn('offers', info)
        self.assertEqual(info['status'], 'success')

    def test_incorrect_book_offers(self):
        incorrect_taker_account = '<KEY>'
        test_issuer_account = '<KEY>'
        get_currency = 'XRP'
        pay_currency = 'USD'
        info = self.rpc.book_offers(taker=incorrect_taker_account, issuer=test_issuer_account,
                                    taker_gets_currency=get_currency, taker_pays_currency=pay_currency)
        self.assertIn('error', info)
        self.assertEqual(info['error'], 'invalidParams')

    def test_ripple_path_find(self):
        destination_account = '<KEY>'
        destination_account_currency = 'USD'
        destination_account_issuer = '<KEY>'
        destination_account_value = '0.001'
        source_account = '<KEY>'
        source_currencies = ['XRP', 'USD']
        info = self.rpc.ripple_path_find(destination_account=destination_account, currency=destination_account_currency,
                                         issuer=destination_account_issuer, value=destination_account_value,
                                         source_account=source_account, source_currencies=source_currencies)
        self.assertIn('alternatives', info)
        self.assertEqual(info['status'], 'success')

    def test_ripple_path_find_no_currencies(self):
        destination_account = '<KEY>'
        destination_account_currency = 'USD'
        destination_account_issuer = '<KEY>'
        destination_account_value = '0.001'
        source_account = '<KEY>'
        source_currencies = []
        info = self.rpc.ripple_path_find(destination_account=destination_account, currency=destination_account_currency,
                                         issuer=destination_account_issuer, value=destination_account_value,
                                         source_account=source_account, source_currencies=source_currencies)
        self.assertIn('error', info)
        self.assertEqual(info['error'], 'srcCurMalformed')
