forked from rethinkdb/rethinkdb-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_database.py
More file actions
56 lines (39 loc) · 1.92 KB
/
Copy pathtest_database.py
File metadata and controls
56 lines (39 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import pytest
from rethinkdb.errors import ReqlRuntimeError
from tests.helpers import INTEGRATION_TEST_DB, IntegrationTestCaseBase
@pytest.mark.integration
class TestDatabase(IntegrationTestCaseBase):
def setup_method(self):
super(TestDatabase, self).setup_method()
self.test_db_name = "test_database"
def test_db_create(self):
result = self.r.db_create(self.test_db_name).run(self.conn)
self.r.db_drop(self.test_db_name).run(self.conn)
assert result["dbs_created"] == 1
assert result["config_changes"][0]["old_val"] is None
assert result["config_changes"][0]["new_val"]["name"] == self.test_db_name
def test_db_create_twice(self):
self.r.db_create(self.test_db_name).run(self.conn)
with pytest.raises(ReqlRuntimeError):
self.r.db_create(self.test_db_name).run(self.conn)
self.r.db_drop(self.test_db_name).run(self.conn)
def test_db_create_not_alphanumeric(self):
test_db_name = "!!!"
with pytest.raises(ReqlRuntimeError):
self.r.db_create(test_db_name).run(self.conn)
def test_db_drop(self):
self.r.db_create(self.test_db_name).run(self.conn)
result = self.r.db_drop(self.test_db_name).run(self.conn)
assert result["dbs_dropped"] == 1
assert result["tables_dropped"] == 0
assert result["config_changes"][0]["new_val"] is None
assert result["config_changes"][0]["old_val"]["name"] == self.test_db_name
def test_db_drop_twice(self):
self.r.db_create(self.test_db_name).run(self.conn)
self.r.db_drop(self.test_db_name).run(self.conn)
with pytest.raises(ReqlRuntimeError):
self.r.db_drop(self.test_db_name).run(self.conn)
def test_db_list(self):
expected_result = [INTEGRATION_TEST_DB, "rethinkdb", "test"]
result = self.r.db_list().run(self.conn)
assert sorted(result) == sorted(expected_result)