-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from hyperskill/sql
Fix running SQL tests
- Loading branch information
Showing
10 changed files
with
118 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
tests/sql/test_queries/execute/test_execute_query_name_with_wrong_query/main.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
create_table = "CRE TABLE contacts ( | ||
contact_id INTEGER PRIMARY KEY, | ||
first_name TEXT NOT NULL, | ||
last_name TEXT NOT NULL, | ||
email TEXT NOT NULL UNIQUE, | ||
phone TEXT NOT NULL UNIQUE | ||
);" | ||
|
||
insert_data = "INSERT INTO contacts VALUES(1, 'first_name', 'last_name', 'email', 'phone');" |
28 changes: 28 additions & 0 deletions
28
tests/sql/test_queries/execute/test_execute_query_name_with_wrong_query/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import unittest | ||
|
||
from hstest import SQLTest, dynamic_test, correct | ||
|
||
|
||
class TestSQLProject(SQLTest): | ||
queries = { | ||
'create_table': None, | ||
'insert_data': None | ||
} | ||
|
||
@dynamic_test | ||
def test_create_table(self): | ||
self.execute('create_table') | ||
|
||
return correct() | ||
|
||
|
||
class Test(unittest.TestCase): | ||
def test(self): | ||
status, feedback = TestSQLProject().run_tests() | ||
self.assertEqual(status, -1) | ||
self.assertIn('Wrong answer in test #1', feedback) | ||
self.assertIn('near "CRE": syntax error', feedback) | ||
|
||
|
||
if __name__ == '__main__': | ||
Test().test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters