Beispiel #1
0
    def test__get_currency_path_without_currency_graph(self):
        """
        Test :meth:`ArbitrageStrategy._get_currency_path`

        Assert that a :class:`MissingCurrencyGraph` exception is raised.
        """

        arbitrage = ArbitrageStrategy()

        currency_graph = MagicMock()

        currency_graph.find_arbitrage_path.side_effect = AttributeError

        with self.assertRaises(MissingCurrencyGraph):
            path, distance = arbitrage._get_currency_path(currency_graph)
Beispiel #2
0
    def test__get_currency_path_with_currency_graph(self):
        """
        Test :meth:`ArbitrageStrategy._get_currency_path`

        Assert the tuple output of :meth:`CurrencyGraph.find_arbitrage_path`
        is returned.
        """

        arbitrage = ArbitrageStrategy()

        currency_graph = MagicMock()

        test_path = ['USD_bid', 'BTC_ask', 'BTC_bid', 'USD_ask']
        TEST_DISTANCE = 1.0
        currency_graph.find_arbitrage_path.return_value = (test_path, TEST_DISTANCE,)

        path, distance = arbitrage._get_currency_path(currency_graph)

        self.assertEqual(path, test_path)
        self.assertEqual(distance, TEST_DISTANCE)