def test_exchange_config_no_bid_ratio(self): bad_config = self.exchange_test_data() del bad_config['test_exchange']['btc']['bid']['ratio'] self.build_exchange_config_file(json.dumps(bad_config)) check = config.check_exchange_config('test_exchange_config') self.assertFalse(check[0]) self.assertEqual(check[1], 'There is no ratio set for test_exchange.btc.bid')
def test_exchange_config_negative_bid_ratio(self): bad_config = self.exchange_test_data() bad_config['test_exchange']['btc']['bid']['ratio'] = -1234 self.build_exchange_config_file(json.dumps(bad_config)) check = config.check_exchange_config('test_exchange_config') self.assertFalse(check[0]) self.assertEqual(check[1], 'The ratio set for test_exchange.btc.bid is incorrect')
def test_exchange_config_no_bid(self): bad_config = self.exchange_test_data() del bad_config['test_exchange']['btc']['bid'] self.build_exchange_config_file(json.dumps(bad_config)) check = config.check_exchange_config('test_exchange_config') self.assertFalse(check[0]) self.assertEqual(check[1], "test_exchange.btc has no 'bid' details")
def test_exchange_config_zero_ask_ratio(self): bad_config = self.exchange_test_data() bad_config['test_exchange']['btc']['ask']['ratio'] = 0 self.build_exchange_config_file(json.dumps(bad_config)) check = config.check_exchange_config('test_exchange_config') self.assertFalse(check[0]) self.assertEqual(check[1], 'The ratio set for test_exchange.btc.ask is incorrect')
def test_exchange_no_reverse_param(self): bad_config = self.exchange_test_data() del bad_config['test_exchange']['btc']['reverse'] self.build_exchange_config_file(json.dumps(bad_config)) check = config.check_exchange_config('test_exchange_config') self.assertFalse(check[0]) self.assertEqual(check[1], 'There is no reverse parameter for test_exchange.btc')
def test_exchange_config_zero_target(self): bad_config = self.exchange_test_data() bad_config['test_exchange']['btc']['target'] = 0 self.build_exchange_config_file(json.dumps(bad_config)) check = config.check_exchange_config('test_exchange_config') self.assertFalse(check[0]) self.assertEqual(check[1], 'The target set for test_exchange.btc is incorrect')
def test_exchange_no_target(self): bad_config = self.exchange_test_data() del bad_config['test_exchange']['btc']['target'] self.build_exchange_config_file(json.dumps(bad_config)) check = config.check_exchange_config('test_exchange_config') self.assertFalse(check[0]) self.assertEqual(check[1], 'There is no target set for test_exchange.btc')
def test_exchange_config_incorrect_exchange(self): ex_config = self.exchange_test_data() bad_config = {'bad_exchange': ex_config['test_exchange']} self.build_exchange_config_file(json.dumps(bad_config)) check = config.check_exchange_config('test_exchange_config') self.assertFalse(check[0]) self.assertEqual(check[1], 'bad_exchange is not a supported exchange')
def test_exchange_config_ask_bid_ratio(self): bad_config = self.exchange_test_data() bad_config['test_exchange']['btc']['ask']['ratio'] = 0.6 bad_config['test_exchange']['btc']['bid']['ratio'] = 0.6 self.build_exchange_config_file(json.dumps(bad_config)) check = config.check_exchange_config('test_exchange_config') self.assertFalse(check[0]) self.assertEqual(check[1], "The ask and bid ratios don't add up to 1.0")
def test_exchange_config_full(self): full_config = self.exchange_test_data() self.build_exchange_config_file(json.dumps(full_config)) check = config.check_exchange_config('test_exchange_config') print check self.assertTrue(check[0])
def test_exchange_config_invalid_json(self): self.build_exchange_config_file('{"test": 1234, }') check = config.check_exchange_config('test_exchange_config') self.assertFalse(check[0]) self.assertEqual(check[1], 'test_exchange_config is not valid json') return