-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change importing of RethinkDB class (#148)
* Fix install-db script * Replace rebirthdb leftovers with rethinkdb * Fix unit tests * Use pytest 5.2.2 on python3+ * Update requirements * Adjust build matrix * Do pip freeze after dependency installation
- Loading branch information
1 parent
00ae565
commit 1d2a81d
Showing
13 changed files
with
128 additions
and
193 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
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
Empty file.
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,47 +1,43 @@ | ||
import os | ||
import sys | ||
from collections import namedtuple | ||
import pytest | ||
from rethinkdb import r | ||
from rethinkdb.errors import ReqlRuntimeError | ||
|
||
Helper = namedtuple("Helper", "r connection") | ||
|
||
INTEGRATION_TEST_DB = 'integration_test' | ||
from asyncio import coroutine | ||
from tests.helpers import INTEGRATION_TEST_DB, IntegrationTestCaseBase | ||
|
||
|
||
@pytest.mark.asyncio | ||
@pytest.mark.integration | ||
@pytest.mark.skipif(sys.version_info < (3, 6), | ||
reason="requires python3.6 or higher") | ||
async def test_flow(): | ||
""" | ||
Test the flow for 3.6 and up, async generators are | ||
not supported in 3.5. | ||
""" | ||
|
||
r.set_loop_type("asyncio") | ||
|
||
connection = await r.connect(os.getenv("REBIRTHDB_HOST")) | ||
|
||
try: | ||
await r.db_create(INTEGRATION_TEST_DB).run(connection) | ||
except ReqlRuntimeError: | ||
pass | ||
|
||
connection.use(INTEGRATION_TEST_DB) | ||
|
||
await r.table_create("marvel").run(connection) | ||
|
||
marvel_heroes = r.table('marvel') | ||
await marvel_heroes.insert({ | ||
'id': 1, | ||
'name': 'Iron Man', | ||
'first_appearance': 'Tales of Suspense #39' | ||
}).run(connection) | ||
|
||
cursor = await marvel_heroes.run(connection) | ||
async for hero in cursor: | ||
assert hero['name'] == 'Iron Man' | ||
|
||
await connection.close() | ||
@pytest.mark.skipif( | ||
sys.version_info == (3, 4) or sys.version_info == (3, 5), | ||
reason="requires python3.4 or python3.5" | ||
) | ||
class TestAsyncio(IntegrationTestCaseBase): | ||
def setup_method(self): | ||
super(TestAsyncio, self).setup_method() | ||
self.table_name = 'test_asyncio' | ||
self.r.set_loop_type('asyncio') | ||
|
||
def teardown_method(self): | ||
super(TestAsyncio, self).teardown_method() | ||
self.r.set_loop_type(None) | ||
|
||
@coroutine | ||
def test_flow_coroutine_paradigm(self): | ||
connection = yield from self.conn | ||
|
||
yield from self.r.table_create(self.table_name).run(connection) | ||
|
||
table = self.r.table(self.table_name) | ||
yield from table.insert({ | ||
'id': 1, | ||
'name': 'Iron Man', | ||
'first_appearance': 'Tales of Suspense #39' | ||
}).run(connection) | ||
|
||
cursor = yield from table.run(connection) | ||
|
||
while (yield from cursor.fetch_next()): | ||
hero = yield from cursor.__anext__() | ||
assert hero['name'] == 'Iron Man' | ||
|
||
yield from connection.close() |
This file was deleted.
Oops, something went wrong.
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,26 +1,27 @@ | ||
import os | ||
import sys | ||
from collections import namedtuple | ||
import pytest | ||
from rethinkdb import r | ||
from rethinkdb.errors import ReqlRuntimeError | ||
|
||
Helper = namedtuple("Helper", "r connection") | ||
|
||
INTEGRATION_TEST_DB = 'integration_test' | ||
from tests.helpers import IntegrationTestCaseBase | ||
|
||
|
||
@pytest.mark.tornado | ||
@pytest.mark.integration | ||
@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires python3.6 or higher") | ||
async def test_tornado_connect(io_loop): | ||
""" | ||
Test the flow for 3.6 and up, async generators are | ||
not supported in 3.5. | ||
""" | ||
class TestTornado(IntegrationTestCaseBase): | ||
def setup_method(self): | ||
super(TestTornado, self).setup_method() | ||
self.table_name = 'test_tornado' | ||
self.r.set_loop_type('tornado') | ||
self.r.table_create(self.table_name).run(self.conn) | ||
|
||
def teardown_method(self): | ||
super(TestTornado, self).teardown_method() | ||
self.r.set_loop_type(None) | ||
|
||
r.set_loop_type("tornado") | ||
async def test_tornado_list_tables(self): | ||
""" | ||
Test the flow for 3.6 and up, async generators are | ||
not supported in 3.5. | ||
""" | ||
|
||
connection = await r.connect(os.getenv("REBIRTHDB_HOST")) | ||
dbs = await r.db_list().run(connection) | ||
assert isinstance(dbs, list) | ||
await connection.close() | ||
tables = self.r.table_list().run(self.conn) | ||
assert isinstance(tables, list) |
Oops, something went wrong.