-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
199 additions
and
33 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
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 |
---|---|---|
@@ -1,22 +1,42 @@ | ||
import unittest | ||
|
||
from pypika import ( | ||
Tables, | ||
Columns, | ||
Database, | ||
Query, | ||
Tables, | ||
) | ||
|
||
|
||
class DropTableTests(unittest.TestCase): | ||
database_xyz = Database("mydb") | ||
new_table, existing_table = Tables("abc", "efg") | ||
foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) | ||
|
||
def test_drop_database(self): | ||
q1 = Query.drop_database(self.database_xyz) | ||
q2 = Query.drop_database(self.database_xyz).if_exists() | ||
|
||
self.assertEqual('DROP DATABASE "mydb"', str(q1)) | ||
self.assertEqual('DROP DATABASE IF EXISTS "mydb"', str(q2)) | ||
|
||
def test_drop_table(self): | ||
q = Query.drop_table(self.new_table) | ||
q1 = Query.drop_table(self.new_table) | ||
q2 = Query.drop_table(self.new_table).if_exists() | ||
|
||
self.assertEqual('DROP TABLE "abc"', str(q1)) | ||
self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q2)) | ||
|
||
def test_drop_user(self): | ||
q1 = Query.drop_user("myuser") | ||
q2 = Query.drop_user("myuser").if_exists() | ||
|
||
self.assertEqual('DROP TABLE "abc"', str(q)) | ||
self.assertEqual('DROP USER "myuser"', str(q1)) | ||
self.assertEqual('DROP USER IF EXISTS "myuser"', str(q2)) | ||
|
||
def test_drop_table_if_exists(self): | ||
q = Query.drop_table(self.new_table).if_exists() | ||
def test_drop_view(self): | ||
q1 = Query.drop_view("myview") | ||
q2 = Query.drop_view("myview").if_exists() | ||
|
||
self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q)) | ||
self.assertEqual('DROP VIEW "myview"', str(q1)) | ||
self.assertEqual('DROP VIEW IF EXISTS "myview"', str(q2)) |