Very new to unit testing so this could be something very easy but I am not sure how to mimic self argument in functions.
Function I want to test:
class dataFeed:
def generateURL(self, ticker, days, period):
return "https://www.google.com/finance/getprices?i=" + str(period) + "&p=" + str(days) + "d&f=d,o,h,l,c,v&df=cpct&q=" + ticker
test class:
import unittest
from dataFeed import dataFeed as df
class TestCases(unittest.TestCase):
def test(self):
self.assertEqual(df.generateURL("AAPL", 2, 5), "https://www.google.com/finance/getprices?i=5&p=2d&f=d,o,h,l,c,v&df=cpct&q=AAPL")
if __name__ == '__main__':
unittest.main()
the output I get is this:
ERROR: test (__main__.TestCases)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\ian\Documents\Capstone\Components\testing.py", line 9, in test
self.assertEqual(df.generateURL("AAPL", 2, 5), "https://www.google.com/finance/getprices?i=5&p=2d&f=d,o,h,l,c,v&df=cpct&q=AAPL")
TypeError: unbound method generateURL() must be called with dataFeed instance as first argument (got str instance instead)