Skip to content

Commit 5e2b03e

Browse files
author
Kareem Zidane
committedMay 27, 2017
added test for multi-insert statements
1 parent f7cf369 commit 5e2b03e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
 

‎tests/sqltests.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
from cs50.sql import SQL
12
import sys
23
import unittest
3-
from cs50.sql import SQL
44
import warnings
55

66
class SQLTests(unittest.TestCase):
7+
def multi_inserts_enabled(self):
8+
return True
9+
710
def test_delete_returns_affected_rows(self):
811
rows = [
912
{"id": 1, "val": "foo"},
@@ -24,6 +27,8 @@ def test_delete_returns_affected_rows(self):
2427
def test_insert_returns_last_row_id(self):
2528
self.assertEqual(self.db.execute("INSERT INTO cs50(val) VALUES('foo')"), 1)
2629
self.assertEqual(self.db.execute("INSERT INTO cs50(val) VALUES('bar')"), 2)
30+
if self.multi_inserts_enabled():
31+
self.assertEqual(self.db.execute("INSERT INTO cs50(val) VALUES('baz'); INSERT INTO cs50(val) VALUES('qux')"), 4)
2732

2833
def test_select_all(self):
2934
self.assertEqual(self.db.execute("SELECT * FROM cs50"), [])
@@ -108,6 +113,9 @@ def setUpClass(self):
108113
def setUp(self):
109114
self.db.execute("CREATE TABLE cs50(id INTEGER PRIMARY KEY, val TEXT)")
110115

116+
def multi_inserts_enabled(self):
117+
return False
118+
111119
if __name__ == "__main__":
112120
suite = unittest.TestSuite([
113121
unittest.TestLoader().loadTestsFromTestCase(SQLiteTests),

0 commit comments

Comments
 (0)
Please sign in to comment.