<s> import unittest <EOL> import mock <EOL> import requests <EOL> import httpretty <EOL> from decouple import config <EOL> from bitfinex . client import Client , TradeClient <EOL> API_KEY = config ( '<STR_LIT>' ) <EOL> API_SECRET = config ( '<STR_LIT>' ) <EOL> class BitfinexTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . client = Client ( ) <EOL> def test_should_have_server ( self ) : <EOL> self . assertEqual ( "<STR_LIT>" , self . client . server ( ) ) <EOL> def test_should_have_url_for_foo ( self ) : <EOL> expected = "<STR_LIT>" <EOL> self . assertEqual ( expected , self . client . url_for ( "<STR_LIT:foo>" ) ) <EOL> def test_should_have_url_for_path_arg ( self ) : <EOL> expected = "<STR_LIT>" <EOL> actual = self . client . url_for ( '<STR_LIT>' , path_arg = "<STR_LIT:bar>" ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_should_have_url_with_parameters ( self ) : <EOL> expected = "<STR_LIT>" <EOL> actual = self . client . url_for ( '<STR_LIT:foo>' , parameters = { '<STR_LIT:a>' : <NUM_LIT:1> , '<STR_LIT:b>' : <NUM_LIT:2> } ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_should_have_url_for ( self ) : <EOL> expected = self . client . url_for ( "<STR_LIT:foo>" ) <EOL> self . assertEqual ( "<STR_LIT>" , expected ) <EOL> def test_should_have_url_for_with_path_arg ( self ) : <EOL> expected = "<STR_LIT>" <EOL> path = "<STR_LIT>" <EOL> self . assertEqual ( expected , self . client . url_for ( path , path_arg = '<STR_LIT:bar>' ) ) <EOL> self . assertEqual ( expected , self . client . url_for ( path , '<STR_LIT:bar>' ) ) <EOL> def test_should_have_url_for_with_parameters ( self ) : <EOL> expected = "<STR_LIT>" <EOL> self . assertEqual ( expected , self . client . url_for ( "<STR_LIT:foo>" , parameters = { '<STR_LIT:a>' : <NUM_LIT:1> } ) ) <EOL> self . assertEqual ( expected , self . client . url_for ( "<STR_LIT:foo>" , None , { '<STR_LIT:a>' : <NUM_LIT:1> } ) ) <EOL> def test_should_have_url_for_with_path_arg_and_parameters ( self ) : <EOL> expected = "<STR_LIT>" <EOL> path = "<STR_LIT>" <EOL> self . assertEqual ( expected , self . client . url_for ( path , path_arg = '<STR_LIT:bar>' , parameters = { '<STR_LIT:a>' : <NUM_LIT:1> } ) ) <EOL> self . assertEqual ( expected , self . client . url_for ( path , '<STR_LIT:bar>' , { '<STR_LIT:a>' : <NUM_LIT:1> } ) ) <EOL> @ httpretty . activate <EOL> def test_should_have_symbols ( self ) : <EOL> mock_body = '<STR_LIT>' <EOL> url = self . client . url_for ( '<STR_LIT>' ) <EOL> httpretty . register_uri ( httpretty . GET , url , body = mock_body , status = <NUM_LIT:200> ) <EOL> expected = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . assertEqual ( expected , self . client . symbols ( ) ) <EOL> @ httpretty . activate <EOL> def test_should_have_ticker ( self ) : <EOL> mock_body = '<STR_LIT>' <EOL> url = self . client . url_for ( '<STR_LIT>' , path_arg = '<STR_LIT>' ) <EOL> httpretty . register_uri ( httpretty . GET , url , body = mock_body , status = <NUM_LIT:200> ) <EOL> expected = { <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } <EOL> self . assertEqual ( expected , self . client . ticker ( '<STR_LIT>' ) ) <EOL> @ httpretty . activate <EOL> def test_should_have_today ( self ) : <EOL> mock_body = '<STR_LIT>' <EOL> url = self . client . url_for ( '<STR_LIT>' , path_arg = '<STR_LIT>' ) <EOL> httpretty . register_uri ( httpretty . GET , url , body = mock_body , status = <NUM_LIT:200> ) <EOL> expected = { <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } <EOL> self . assertEqual ( expected , self . client . today ( '<STR_LIT>' ) ) <EOL> @ httpretty . activate <EOL> def test_should_have_stats ( self ) : <EOL> mock_body = '<STR_LIT>' <EOL> url = self . client . url_for ( '<STR_LIT>' , path_arg = '<STR_LIT>' ) <EOL> httpretty . register_uri ( httpretty . GET , url , body = mock_body , status = <NUM_LIT:200> ) <EOL> expected = [ <EOL> { "<STR_LIT>" : <NUM_LIT:1> , "<STR_LIT>" : <NUM_LIT> } , <EOL> { "<STR_LIT>" : <NUM_LIT:7> , "<STR_LIT>" : <NUM_LIT> } , <EOL> { "<STR_LIT>" : <NUM_LIT:30> , "<STR_LIT>" : <NUM_LIT> } <EOL> ] <EOL> self . assertEqual ( expected , self . client . stats ( '<STR_LIT>' ) ) <EOL> @ httpretty . activate <EOL> def test_should_have_lendbook ( self ) : <EOL> mock_body = '<STR_LIT>' <EOL> url = self . client . url_for ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> httpretty . register_uri ( httpretty . GET , url , body = mock_body , status = <NUM_LIT:200> ) <EOL> expected = { <EOL> "<STR_LIT>" : [ <EOL> { "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT:30> , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : False } , <EOL> { "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT:7> , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : False } <EOL> ] , <EOL> "<STR_LIT>" : [ <EOL> { "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT:5> , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : False } , <EOL> { "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT:30> , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : True } <EOL> ] <EOL> } <EOL> self . assertEqual ( expected , self . client . lendbook ( '<STR_LIT>' ) ) <EOL> @ httpretty . activate <EOL> def test_should_have_lendbook_with_parameters ( self ) : <EOL> mock_body = '<STR_LIT>' <EOL> parameters = { '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : <NUM_LIT:0> } <EOL> url = self . client . url_for ( '<STR_LIT>' , '<STR_LIT>' , parameters ) <EOL> httpretty . register_uri ( httpretty . GET , url , body = mock_body , status = <NUM_LIT:200> ) <EOL> expected = { <EOL> "<STR_LIT>" : [ <EOL> { "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT:30> , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : False } , <EOL> { "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT:7> , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : False } <EOL> ] , <EOL> "<STR_LIT>" : [ <EOL> ] <EOL> } <EOL> self . assertEqual ( expected , self . client . lendbook ( '<STR_LIT>' , parameters ) ) <EOL> @ httpretty . activate <EOL> def test_should_have_order_book ( self ) : <EOL> mock_body = '<STR_LIT>' <EOL> url = self . client . url_for ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> httpretty . register_uri ( httpretty . GET , url , body = mock_body , status = <NUM_LIT:200> ) <EOL> expected = { <EOL> "<STR_LIT>" : [ <EOL> { "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT> } <EOL> ] , <EOL> "<STR_LIT>" : [ <EOL> { "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT> } <EOL> ] <EOL> } <EOL> self . assertEqual ( expected , self . client . order_book ( '<STR_LIT>' ) ) <EOL> @ httpretty . activate <EOL> def test_should_have_order_book_with_parameters ( self ) : <EOL> mock_body = '<STR_LIT>' <EOL> parameters = { '<STR_LIT>' : <NUM_LIT:0> } <EOL> url = self . client . url_for ( '<STR_LIT>' , '<STR_LIT>' , parameters ) <EOL> httpretty . register_uri ( httpretty . GET , url , body = mock_body , status = <NUM_LIT:200> ) <EOL> expected = { <EOL> "<STR_LIT>" : [ <EOL> { "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT> } <EOL> ] , <EOL> "<STR_LIT>" : [ ] <EOL> } <EOL> self . assertEqual ( expected , self . client . order_book ( '<STR_LIT>' , parameters ) ) <EOL> class TestTradeClient ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . tc = TradeClient ( API_KEY , API_SECRET ) <EOL> def test_instantiate_tradeclient ( self ) : <EOL> self . assertIsInstance ( self . tc , TradeClient ) <EOL> def test_get_active_orders_returns_json ( self ) : <EOL> ao = self . tc . active_orders ( ) <EOL> self . assertIsInstance ( ao , list ) <EOL> def test_get_active_positions_returns_json ( self ) : <EOL> ap = self . tc . active_positions ( ) <EOL> self . assertIsInstance ( ap , list ) <EOL> def test_get_full_history ( self ) : <EOL> ap = self . tc . active_positions ( ) <EOL> self . assertIsInstance ( ap , list ) </s>
