Exemple #1
0
 def test_update_holding_wrong_id(self):
     '''test that update works with wrong id given'''
     teardown_user()
     teardown_holdings()
     setup_user()
     setup_holdings()
     update_holding(2, 8, 10, 10, "test_pymarket.db")
     query = '''SELECT * FROM holdings where holdingID=? and userID=?'''
     cursor.execute(query, [(8), (4)])
     self.assertEqual(cursor.fetchall()[0][3], 11.24)
Exemple #2
0
 def test_update_holding(self):
     '''test that update works in general'''
     teardown_user()
     teardown_holdings()
     setup_user()
     setup_holdings()
     update_holding(4, 8, 10, 10, "test_pymarket.db")
     query = '''SELECT * FROM holdings where holdingID=? and userID=?'''
     cursor.execute(query, [(8), (4)])
     self.assertEqual(cursor.fetchall()[0][3], 10.0)
Exemple #3
0
 def test_delete_holding_not_exist(self):
     '''test that remove works with an invalid holding, doesn't crash'''
     teardown_user()
     teardown_holdings()
     setup_user()
     setup_holdings()
     delete_holding(2, 8, "test_pymarket.db")
     query = '''SELECT * FROM holdings where holdingID=? and userID=?'''
     cursor.execute(query, [(8), (2)])
     self.assertCountEqual([], cursor.fetchall())
Exemple #4
0
 def test_delete_holding(self):
     '''test that remove works in general'''
     teardown_user()
     teardown_holdings()
     setup_user()
     setup_holdings()
     delete_holding(4, 8, "test_pymarket.db")
     query = '''SELECT * FROM holdings where holdingID=? and userID=?'''
     cursor.execute(query, [(8), (4)])
     self.assertCountEqual([], cursor.fetchall())
Exemple #5
0
 def test_make_holding_string_inputs(self):
     '''test that the function still works with all string inputs'''
     teardown_user()
     teardown_holdings()
     setup_user()
     setup_holdings()
     make_holding('1', 'TEUM', '8.09', '1.27', '1', "test_pymarket.db")
     query = '''SELECT * FROM holdings where holdingID=? and userID=?'''
     cursor.execute(query, [(18), (1)])
     self.assertCountEqual([(18, 1, 'TEUM', 8.09, 1.27, 1)],
                           cursor.fetchall())
Exemple #6
0
    def test_make_holding(self):
        '''test that make works in general, no need to test if user doesn't exist,
	 		since function only called when logged in'''
        teardown_user()
        teardown_holdings()
        setup_user()
        setup_holdings()
        make_holding(1, 'TEUM', 8.09, 1.27, 1, "test_pymarket.db")
        query = '''SELECT * FROM holdings where holdingID=? and userID=?'''
        cursor.execute(query, [(18), (1)])
        self.assertCountEqual([(18, 1, 'TEUM', 8.09, 1.27, 1)],
                              cursor.fetchall())