diff options
author | 2018-05-20 21:11:18 +0200 | |
---|---|---|
committer | 2018-05-20 21:11:18 +0200 | |
commit | 687fedfffa402e049c59668f2a6248ad2ba17910 (patch) | |
tree | 834e909781213650b40508398ed5a9bef10686c5 /tests/test_database.py | |
parent | remove set -e (diff) |
Tests directory (#73)
moves all tests into a testing directory and splits the tests into separate files
Diffstat (limited to 'tests/test_database.py')
-rw-r--r-- | tests/test_database.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test_database.py b/tests/test_database.py new file mode 100644 index 00000000..237cd68d --- /dev/null +++ b/tests/test_database.py @@ -0,0 +1,31 @@ +from tests import SiteTest + +class DatabaseTests(SiteTest): + """ Test cases for the database module """ + def test_table_actions(self): + import string + import secrets + from pysite.database import RethinkDB + + alphabet = string.ascii_letters + generated_table_name = ''.join(secrets.choice(alphabet) for i in range(8)) + + rdb = RethinkDB() + # Create table name and expect it to work + result = rdb.create_table(generated_table_name) + self.assertEqual(result, True) + + # Create the same table name and expect it to already exist + result = rdb.create_table(generated_table_name) + self.assertEqual(result, False) + + # Drop table and expect it to work + result = rdb.drop_table(generated_table_name) + self.assertEqual(result, True) + + # Drop the same table and expect it to already be gone + result = rdb.drop_table(generated_table_name) + self.assertEqual(result, False) + + # This is to get some more code coverage + self.assertEqual(rdb.teardown_request('_'), None) |