# book_tester.py
# -------
# Tests for databases.py BookDatabase
import databases as d

bdb = d.BookDatabase("../reduced_compustat_full.csv")

"""
for row in bdb.data["MDT"]:
    print(row)
['7228', '20000131', '1999', '3', 'MDT', '20000223', '4119.2', '300']
['7228', '20000430', '1999', '4', 'MDT', '20000524', '4491.5', '300']
['7228', '20000731', '2000', '1', 'MDT', '20000821', '4739.1', '300']
['7228', '20001031', '2000', '2', 'MDT', '20001120', '4964.1', '300']
['7228', '20010131', '2000', '3', 'MDT', '20010221', '5358.7', '300']
['7228', '20010430', '2000', '4', 'MDT', '20010522', '5509.5', '300']
['7228', '20010731', '2001', '1', 'MDT', '20010820', '5772.5', '300']
['7228', '20011031', '2001', '2', 'MDT', '20011127', '5831.5', '300']
['7228', '20020131', '2001', '3', 'MDT', '20020220', '6163.2', '300']
['7228', '20020430', '2001', '4', 'MDT', '20020522', '6431.1', '300']
['7228', '20020731', '2002', '1', 'MDT', '20020820', '6731.3', '300']
['7228', '20021031', '2002', '2', 'MDT', '20021118', '7181.1', '300']
['7228', '20030131', '2002', '3', 'MDT', '20030307', '7572.8', '300']
['7228', '20030430', '2002', '4', 'MDT', '20030519', '7906.4', '300']
['7228', '20030731', '2003', '1', 'MDT', '20030812', '8176.7', '300']
['7228', '20031031', '2003', '2', 'MDT', '20031112', '8301.9', '300']
['7228', '20040131', '2003', '3', 'MDT', '20040211', '8687.5', '300']
['7228', '20040430', '2003', '4', 'MDT', '20040524', '9077.0', '300']
['7228', '20040731', '2004', '1', 'MDT', '20040818', '9448.1', '300']
['7228', '20041031', '2004', '2', 'MDT', '20041117', '9925.3', '300']
['7228', '20050131', '2004', '3', 'MDT', '20050216', '10232.1', '300']
['7228', '20050430', '2004', '4', 'MDT', '20050524', '10449.5', '300']
['7228', '20050731', '2005', '1', 'MDT', '20050817', '10580.8', '300']
['7228', '20051031', '2005', '2', 'MDT', '20051116', '11133.7', '300']
['7228', '20060131', '2005', '3', 'MDT', '20060221', '11737.6', '300']
['7228', '20060430', '2005', '4', 'MDT', '20060523', '9382.5', '300']
['7228', '20060731', '2006', '1', 'MDT', '20060822', '9896.0', '300']
['7228', '20061031', '2006', '2', 'MDT', '20061120', '10277.0', '300']
['7228', '20070131', '2006', '3', 'MDT', '20070220', '10984.0', '300']
['7228', '20070430', '2006', '4', 'MDT', '20070522', '10977.0', '300']
['7228', '20070731', '2007', '1', 'MDT', '20070821', '11143.0', '300']
['7228', '20071031', '2007', '2', 'MDT', '20071119', '11475.0', '300']
['7228', '20080131', '2007', '3', 'MDT', '20080219', '10966.0', '300']
['7228', '20080430', '2007', '4', 'MDT', '20080520', '11536.0', '300']
['7228', '20080731', '2008', '1', 'MDT', '20080819', '12239.0', '300']
['7228', '20081031', '2008', '2', 'MDT', '20081118', '12624.0', '300']
['7228', '20090131', '2008', '3', 'MDT', '20090217', '13064.0', '300']
['7228', '20090430', '2008', '4', 'MDT', '20090519', '12851.0', '300']
['7228', '20090731', '2009', '1', 'MDT', '20090825', '13144.0', '300']
['7228', '20091031', '2009', '2', 'MDT', '20091124', '13608.0', '300']
['7228', '20100131', '2009', '3', 'MDT', '20100223', '14320.0', '300']
['7228', '20100430', '2009', '4', 'MDT', '20100525', '14629.0', '300']
['7228', '20100731', '2010', '1', 'MDT', '20100824', '14601.0', '300']
['7228', '20101031', '2010', '2', 'MDT', '20101123', '14825.0', '300']
['7228', '20110131', '2010', '3', 'MDT', '20110222', '15358.0', '300']
['7228', '20110430', '2010', '4', 'MDT', '20110524', '15968.0', '300']
['7228', '20110731', '2011', '1', 'MDT', '20110823', '16340.0', '300']
['7228', '20111031', '2011', '2', 'MDT', '20111122', '16739.0', '300']
['7228', '20120131', '2011', '3', 'MDT', '20120221', '17169.0', '300']
['7228', '20120430', '2011', '4', 'MDT', '20120522', '17113.0', '300']
['7228', '20120731', '2012', '1', 'MDT', '20120821', '17255.0', '300']
['7228', '20121031', '2012', '2', 'MDT', '20121120', '17175.0', '300']
['7228', '20130131', '2012', '3', 'MDT', '20130219', '17836.0', '300']
['7228', '20130430', '2012', '4', 'MDT', '20130521', '18671.0', '300']
['7228', '20130731', '2013', '1', 'MDT', '20130820', '18519.0', '300']
['7228', '20131031', '2013', '2', 'MDT', '20131119', '18744.0', '300']
['7228', '20140131', '2013', '3', 'MDT', '20140218', '19354.0', '300']
['7228', '20140430', '2013', '4', 'MDT', '20140520', '19443.0', '300']
['7228', '20140731', '2014', '1', 'MDT', '20140819', '19248.0', '300']
['7228', '20141031', '2014', '2', 'MDT', '20141118', '19438.0', '300']
['7228', '20150131', '2014', '3', 'MDT', '20150217', '20173.0', '300']
['7228', '20150430', '2014', '4', 'MDT', '20150602', '53230.0', '300']
['7228', '20150731', '2015', '1', 'MDT', '20150903', '52809.0', '300']
['7228', '20151031', '2015', '2', 'MDT', '20151203', '52269.0', '300']
['7228', '20160131', '2015', '3', 'MDT', '20160301', '50816.0', '300']
['7228', '20160430', '2015', '4', 'MDT', '20160531', '52063.0', '300']
['7228', '20160731', '2016', '1', 'MDT', '20160825', '50824.0', '300']
['7228', '20161031', '2016', '2', 'MDT', '20161122', '50186.0', '300']
['7228', '20170131', '2016', '3', 'MDT', '20170221', '49387.0', '300']
['7228', '20170430', '2016', '4', 'MDT', '20170525', '50294.0', '300']
['7228', '20170731', '2017', '1', 'MDT', '20170822', '50672.0', '300']
['7228', '20171031', '2017', '2', 'MDT', '20171121', '51469.0', '300']
['7228', '20180131', '2017', '3', 'MDT', '20180220', '50234.0', '300']
['7228', '20180430', '2017', '4', 'MDT', '20180524', '50720.0', '300']
['7228', '20180731', '2018', '1', 'MDT', '20180821', '50224.0', '300']
['7228', '20181031', '2018', '2', 'MDT', '20181120', '49607.0', '300']
"""

print("Expected: -1 Actual: " + str(bdb.getBookValue("MDT", "20000121")))
print("Expected: -1 Actual: " + str(bdb.getBookValue("MDT", "20000131")))
print("Expected: 50224000000 Actual: " + str(bdb.getBookValue("MDT", "20181031")))
print("Expected: 49607000000 Actual: " + str(bdb.getBookValue("MDT", "20181121")))
print("Expected: 4119200000 Actual: " + str(bdb.getBookValue("MDT", "20000231")))
print("Expected: 50720000000 Actual: " + str(bdb.getBookValue("MDT", "20180630")))
print("Expected: 300 Actual: " + bdb.industryCode("MDT"))
print("Expected: True Actual: " + str(bdb.isReportDate("MDT", "20181120")))
print("Expected: False Actual: " + str(bdb.isReportDate("MDT", "20181121")))


