Open ishika-a opened 4 years ago
import unittest from client3 import *
class ClientTest(unittest.TestCase): def test_getDataPoint_calculatePrice(self): quotes = [ {'top_ask': {'price': 121.2, 'size': 36}, 'timestamp': '2019-02-11 22:06:30.572453', 'top_bid': {'price': 120.48, 'size': 109}, 'id': '0.109974697771', 'stock': 'ABC'}, {'top_ask': {'price': 121.68, 'size': 4}, 'timestamp': '2019-02-11 22:06:30.572453', 'top_bid': {'price': 117.87, 'size': 81}, 'id': '0.109974697771', 'stock': 'DEF'} ] """ ------------ Add the assertion below ------------ """
def test_getDataPoint_calculatePriceBidGreaterThanAsk(self): quotes = [ {'top_ask': {'price': 119.2, 'size': 36}, 'timestamp': '2019-02-11 22:06:30.572453', 'top_bid': {'price': 120.48, 'size': 109}, 'id': '0.109974697771', 'stock': 'ABC'}, {'top_ask': {'price': 121.68, 'size': 4}, 'timestamp': '2019-02-11 22:06:30.572453', 'top_bid': {'price': 117.87, 'size': 81}, 'id': '0.109974697771', 'stock': 'DEF'} ] """ ------------ Add the assertion below ------------ """ def test_getRatio_calculate0(self): z=getRatio(125,0) self.assertIsNone(z) y=getRatio(0,122) self.assertEqual(y,0)
""" ------------ Add more unit tests ------------ """
if name == 'main': unittest.main()
import unittest from client3 import *
class ClientTest(unittest.TestCase): def test_getDataPoint_calculatePrice(self): quotes = [ {'top_ask': {'price': 121.2, 'size': 36}, 'timestamp': '2019-02-11 22:06:30.572453', 'top_bid': {'price': 120.48, 'size': 109}, 'id': '0.109974697771', 'stock': 'ABC'}, {'top_ask': {'price': 121.68, 'size': 4}, 'timestamp': '2019-02-11 22:06:30.572453', 'top_bid': {'price': 117.87, 'size': 81}, 'id': '0.109974697771', 'stock': 'DEF'} ] """ ------------ Add the assertion below ------------ """
def test_getDataPoint_calculatePriceBidGreaterThanAsk(self): quotes = [ {'top_ask': {'price': 119.2, 'size': 36}, 'timestamp': '2019-02-11 22:06:30.572453', 'top_bid': {'price': 120.48, 'size': 109}, 'id': '0.109974697771', 'stock': 'ABC'}, {'top_ask': {'price': 121.68, 'size': 4}, 'timestamp': '2019-02-11 22:06:30.572453', 'top_bid': {'price': 117.87, 'size': 81}, 'id': '0.109974697771', 'stock': 'DEF'} ] """ ------------ Add the assertion below ------------ """ def test_getRatio_calculate0(self): z=getRatio(125,0) self.assertIsNone(z) y=getRatio(0,122) self.assertEqual(y,0)
""" ------------ Add more unit tests ------------ """
if name == 'main': unittest.main()