コード例 #1
0
 def test(self):
     testCases: List[Case] = [
         Case(
             desc='success',
             runner=lambda cli: cli.cancelOrders(id=5, ),
             reqMethod='put',
             reqPath='/orders/5/cancel',
             resStatus=200,
             resBody='''
             {
                 "id": 1,
                 "order_type": "limit"
             }
             ''',
             expected=Order(
                 id=1,
                 order_type='limit',
             ),
         ),
     ]
     for tc in testCases:
         with self.subTest(desc=tc.desc):
             assertHTTPRequest(
                 self,
                 tc.reqMethod,
                 tc.reqPath,
                 tc.reqParams,
                 tc.reqData,
                 DEFAULT_REQUEST_HEADERS,
                 tc.resStatus,
                 tc.resBody,
                 tc.runner,
                 tc.expected,
                 tc.expectedErrMsg,
             )
コード例 #2
0
 def test(self):
     testCases = [
         {
             'desc':
             'success',
             'inputCPair':
             'BTCJPY',
             'inputLimit':
             2,
             'inputTimestamp':
             3,
             'resStatus':
             200,
             'resBody':
             '''
             [
                 {
                     "id": 100,
                     "quantity": 0.01,
                     "price": 100.100,
                     "taker_side": "sell",
                     "created_at": 1
                 }
             ]
             ''',
             'expected': [
                 Execution(
                     id=100,
                     quantity=0.01,
                     price=100.100,
                     taker_side='sell',
                     created_at=1,
                 ),
             ],
         },
     ]
     for tc in testCases:
         with self.subTest(desc=tc['desc']):
             assertHTTPRequest(
                 self,
                 'get',
                 '/executions',
                 {
                     'currency_pair_code': tc['inputCPair'],
                     'timestamp': tc['inputTimestamp'],
                     'limit': tc['inputLimit'],
                 },
                 None,
                 DEFAULT_REQUEST_HEADERS,
                 tc['resStatus'],
                 tc['resBody'],
                 lambda cli: cli.getExecutionsByTimestamp(
                     tc['inputCPair'],
                     tc['inputTimestamp'],
                     tc['inputLimit'],
                 ),
                 tc.get('expected', None),
                 tc.get('expectedErr', None),
             )
コード例 #3
0
 def test(self):
     testCases = [
         {
             'desc':
             'success',
             'resStatus':
             200,
             'resBody':
             '''
             [
                 {
                     "id": 1,
                     "currency": "JPY",
                     "currency_symbol": "¥",
                     "balance": 20.00,
                     "reserved_balance": 30.00,
                     "pusher_channel": "dummy001",
                     "lowest_offer_interest_rate": 40.00,
                     "highest_offer_interest_rate": 50.00,
                     "exchange_rate": 60.00,
                     "currency_type": "fiat"
                 }
             ]
             ''',
             'expected': [
                 FiatAccount(
                     id=1,
                     currency='JPY',
                     currency_symbol='¥',
                     balance=20.00,
                     reserved_balance=30.00,
                     pusher_channel='dummy001',
                     lowest_offer_interest_rate=40.00,
                     highest_offer_interest_rate=50.00,
                     exchange_rate=60.00,
                     currency_type='fiat',
                 ),
             ],
         },
     ]
     for tc in testCases:
         with self.subTest(desc=tc['desc']):
             assertHTTPRequest(
                 self,
                 'get',
                 '/fiat_accounts',
                 None,
                 None,
                 DEFAULT_REQUEST_HEADERS,
                 tc['resStatus'],
                 tc['resBody'],
                 lambda cli: cli.getFiatAccounts(),
                 tc.get('expected', None),
                 tc.get('expectedErr', None),
             )
コード例 #4
0
 def test(self):
     testCases: List[Case] = [
         Case(
             desc='success',
             runner=lambda cli: cli.getOrders(),
             reqMethod='get',
             reqPath='/orders',
             resStatus=200,
             resBody='''
             {
                 "current_page": 1,
                 "total_pages": 999,
                 "models": [
                     {
                         "id": 100,
                         "order_type": "limit",
                         "side": "buy",
                         "price": 100.100,
                         "quantity": 0.01
                     }
                 ]
             }
             ''',
             expected=Page(
                 current_page=1,
                 total_pages=999,
                 models=[
                     Order(
                         id=100,
                         order_type='limit',
                         side='buy',
                         price=100.100,
                         quantity=0.01,
                     ),
                 ],
             ),
         ),
     ]
     for tc in testCases:
         with self.subTest(desc=tc.desc):
             assertHTTPRequest(
                 self,
                 tc.reqMethod,
                 tc.reqPath,
                 tc.reqParams,
                 tc.reqData,
                 DEFAULT_REQUEST_HEADERS,
                 tc.resStatus,
                 tc.resBody,
                 tc.runner,
                 tc.expected,
                 tc.expectedErrMsg,
             )
コード例 #5
0
 def testHTTPError(self):
     testCases = [
         (404, '404 Client Error'),
         (500, '500 Server Error'),
     ]
     for tc in testCases:
         self.subTest(code=tc[0])
         assertHTTPRequest(
             self, 'get', '/',
             {}, None, {},
             tc[0], 'Dummy',
             lambda cli: cli.getExecutions(1, 1, 1),
             {}, tc[1],
         )
コード例 #6
0
 def test(self):
     testCases: List[Case] = [
         Case(
             desc='success',
             runner=lambda cli: cli.postOrders(
                 product_id=5,
                 order_type='limit',
                 side='buy',
                 quantity=0.01,
                 price=500.0,
             ),
             reqMethod='post',
             reqPath='/orders',
             reqData={
                 'order': {
                     'order_type': 'limit',
                     'product_id': 5,
                     'side': 'buy',
                     'quantity': 0.01,
                     'price': 500.0,
                 },
             },
             resStatus=200,
             resBody='''
             {
                 "id": 1,
                 "order_type": "limit"
             }
             ''',
             expected=Order(
                 id=1,
                 order_type='limit',
             ),
         ),
     ]
     for tc in testCases:
         with self.subTest(desc=tc.desc):
             assertHTTPRequest(
                 self,
                 tc.reqMethod,
                 tc.reqPath,
                 tc.reqParams,
                 tc.reqData,
                 DEFAULT_REQUEST_HEADERS,
                 tc.resStatus,
                 tc.resBody,
                 tc.runner,
                 tc.expected,
                 tc.expectedErrMsg,
             )
コード例 #7
0
 def test(self):
     testCases: List[Case] = [
         Case(
             desc='success',
             runner=lambda cli: cli.getOrdersById(1000),
             reqMethod='get',
             reqPath='/orders/1000',
             resStatus=200,
             resBody='''
             {
                 "id": 100,
                 "order_type": "limit",
                 "side": "buy",
                 "price": 100.100,
                 "quantity": 0.01
             }
             ''',
             expected=Order(
                 id=100,
                 order_type='limit',
                 side='buy',
                 price=100.100,
                 quantity=0.01,
             ),
         ),
     ]
     for tc in testCases:
         with self.subTest(desc=tc.desc):
             assertHTTPRequest(
                 self,
                 tc.reqMethod,
                 tc.reqPath,
                 tc.reqParams,
                 tc.reqData,
                 DEFAULT_REQUEST_HEADERS,
                 tc.resStatus,
                 tc.resBody,
                 tc.runner,
                 tc.expected,
                 tc.expectedErrMsg,
             )
コード例 #8
0
 def test(self):
     testCases = [
         {
             'desc':
             'success',
             'inputProductId':
             1,
             'inputLimit':
             1,
             'inputPage':
             1,
             'resStatus':
             200,
             'resBody':
             '''
             {
                 "current_page": 1,
                 "total_pages": 999,
                 "models": [
                     {
                         "id": 100,
                         "quantity": 0.01,
                         "price": 100.100,
                         "taker_side": "sell",
                         "created_at": 1
                     }
                 ]
             }
             ''',
             'expected':
             Page(
                 current_page=1,
                 total_pages=999,
                 models=[
                     Execution(
                         id=100,
                         quantity=0.01,
                         price=100.100,
                         taker_side='sell',
                         created_at=1,
                     ),
                 ],
             ),
         },
     ]
     for tc in testCases:
         with self.subTest(desc=tc['desc']):
             assertHTTPRequest(
                 self,
                 'get',
                 '/executions',
                 {
                     'product_id': tc['inputProductId'],
                     'limit': tc['inputLimit'],
                     'page': tc['inputPage'],
                 },
                 None,
                 DEFAULT_REQUEST_HEADERS,
                 tc['resStatus'],
                 tc['resBody'],
                 lambda cli: cli.getExecutions(
                     tc['inputProductId'],
                     tc['inputLimit'],
                     tc['inputPage'],
                 ),
                 tc.get('expected', None),
                 tc.get('expectedErr', None),
             )