insidesherpa / JPMC-tech-task-1

56 stars 350 forks source link

dict object is not callable #118

Open BrijeshChandra7 opened 4 years ago

BrijeshChandra7 commented 4 years ago

image the above error im getting due to this client_test.py file code that i created

import unittest from client3 import getDataPoint, getRatio

class ClientTest(unittest.TestCase): def test_getRatio_calculateratio(self): price_a=[2,3,4,5,6,7,8]
price_b=[1,2,3,4,5,6,7] for i in range(7): self.assertEqual(getRatio(price_a[i],price_b[i]),(price_a[i]/price_b[i])) 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'} ]

for quote in quotes:
  self.assertEqual(getDataPoint(quote), (quote('stock'), quote['top_bid']['price'], quot['top_ask']['price'], (quote['top_bid']['price'] + quote['top_ask']['price'])/2))

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'} ]

for quote in quotes:
  self.assertEqual(getDataPoint(quote), (quote('stock'), quote['top_bid']['price'], quote['top_ask']['price'], (quote['top_bid']['price'] + quote['top_ask']['price'])/2))    

""" ------------ Add more unit tests ------------ """

if name == 'main': unittest.main()

therajaryan commented 4 years ago

Do not use curly brackets. Write quote['stock'] instead of quote('stock'). This should solve the problem.