예제 #1
0
    def test_ending_after_last_stored_is_less_than_config(self, *args):
        configuration = BudaMarketConfig()
        self.market_config.last_stored_timestamp = get_entries_list()[10][0]
        self.market_config.recovered_all = True

        configuration.btc = self.market_config
        buda = BudaIntegration(configuration)
        buda.should_log = False

        with mock.patch('core.BaseIntegration.requests.get',
                        side_effect=self.mock_request_get):
            self.should_block = True
            buda.recover_btc()

        self.assertEqual(1, self.request_call_count)
예제 #2
0
    def test_wait_after_ddos_block(self, *args):
        configuration = BudaMarketConfig()
        configuration.btc = self.market_config

        buda = BudaIntegration(configuration)
        buda.should_log = False

        with mock.patch('core.BaseIntegration.requests.get',
                        side_effect=self.mock_request_get):
            self.should_block = True
            buda.recover_btc()

        self.assertEqual(args[0].call_count, 3)
        self.assertEqual(self.request_call_count, 3)
        self.assertTrue(self.market_config.recovered_all)
예제 #3
0
    def test_executed_request_happy_case_not_recovered_all(self, *args):
        configuration = BudaMarketConfig()
        configuration.btc = self.market_config

        buda = BudaIntegration(configuration)
        # date utils gettz works as expected when used from cli, but fails when unittesting on
        # ubuntu (in windows works well) maybe it is related to mocking open() function (?)
        buda.should_log = False

        with mock.patch('core.BaseIntegration.requests.get',
                        side_effect=self.mock_request_get):
            buda.recover_btc()

        self.assertGreaterEqual(self.request_call_count, 3)
        self.assertTrue(self.market_config.recovered_all)
예제 #4
0
    def test_from_dict_child_config(self):
        self.base_config['buda']['btc']['last_stored_timestamp'] = 1
        self.base_config['buda']['btc']['most_recent_timestamp'] = 2
        self.base_config['buda']['btc']['first_stored_timestamp'] = 3
        self.base_config['buda']['btc']['current_request_timestamp'] = 4

        config_obj = BudaMarketConfig.from_dict(self.base_config['buda'])
        self.compare_config_with_dict(config_obj, self.base_config['buda'])
예제 #5
0
def root_config_from_dict(config_dict: dict) -> RootConfig:
    if _is_valid_dict(config_dict):
        root_instance = RootConfig.get_instanciator()

        buda = BudaMarketConfig.from_dict(config_dict['buda'])
        buda.root_config = root_instance

        crypto_compare = CryptoCompareConfig.from_dict(
            config_dict['crypto_compare'])
        crypto_compare.root_config = root_instance

        root_instance.buda = buda
        root_instance.crypto_compare = crypto_compare

        return root_instance
    else:
        raise TypeError('Cannot reconstruct Root config from config file')
예제 #6
0
 def setUp(self):
     self.request_call_count = 0
     self.should_block = False
     self.market_config = MarketConfig('btc')
     self.buda_integration = BudaIntegration(BudaMarketConfig())
     self.buda_integration.should_log = False