-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added some test for manual connectors and test for DsDbManager
- Loading branch information
1 parent
49ee5d6
commit c602192
Showing
3 changed files
with
176 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import unittest | ||
from dsdbmanager.mssql_ import Mssql | ||
from dsdbmanager.mysql_ import Mysql | ||
from dsdbmanager.oracle_ import Oracle | ||
from dsdbmanager.teradata_ import Teradata | ||
from dsdbmanager.exceptions_ import MissingFlavor, MissingDatabase, MissingPackage | ||
|
||
|
||
class TestConnectors(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
cls.host_dict = { | ||
'oracle': { | ||
'database1': { | ||
'name': 'database1', | ||
'host': 'somehost', | ||
'port': 0000 | ||
} | ||
}, | ||
'teradata': { | ||
'database1': { | ||
'name': 'database1', | ||
'host': 'somehost', | ||
} | ||
}, | ||
'mssql': { | ||
'database1': { | ||
'name': 'database1', | ||
'host': 'somehost', | ||
'port': 0000 | ||
} | ||
}, | ||
'mysql': { | ||
'database1': { | ||
'name': 'database1', | ||
'host': 'somehost', | ||
'port': 0000 | ||
} | ||
} | ||
} | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
pass | ||
|
||
def test_connectors(self): | ||
for name, connector in zip( | ||
[ | ||
'oracle', | ||
'mysql', | ||
'mssql', | ||
'teradata', | ||
], | ||
[ | ||
Oracle, | ||
Mysql, | ||
Mssql, | ||
Teradata, | ||
]): | ||
with self.subTest(flavor=name): | ||
# test with host improper host file. should raise MissingFlavor | ||
with self.assertRaises(MissingFlavor): | ||
_ = connector('database1', {'host': 'dummy'}) | ||
|
||
# test for database that has not been added | ||
with self.assertRaises(MissingDatabase): | ||
_ = connector('database2', self.host_dict) | ||
|
||
# test for database added | ||
obj = connector('database1', self.host_dict) | ||
self.assertTrue(hasattr(obj, 'create_engine')) | ||
|
||
# this is only useful in an environment where none of the extra packages are available | ||
# with self.assertRaises(MissingPackage): | ||
# obj.create_engine() | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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