Skip to content

Commit

Permalink
Merge pull request #16 from Inveracity/update-dependencies
Browse files Browse the repository at this point in the history
updated dependencies
  • Loading branch information
Inveracity committed Jul 26, 2023
2 parents 1e84705 + 4bad8ef commit db4764f
Show file tree
Hide file tree
Showing 15 changed files with 324 additions and 285 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:

steps:
- name: Checkout the repo and the submodules.
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: "3.9"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:

steps:
- name: Checkout the repo and the submodules.
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: "3.9"

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/rethinkdb_mock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -37,7 +37,7 @@ jobs:
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV
- name: Coverage badge
uses: schneegans/dynamic-badges-action@v1.0.0
uses: schneegans/dynamic-badges-action@v1.6.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: bade1568c33344c896cbfa5cdef91270
Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pytest-server-fixtures = "*"
future = "*"
python-dateutil = "*"
rethinkdb = ">=2.4.8"
exceptiongroup = "*"

[requires]
python_version = "3"
Expand Down
480 changes: 258 additions & 222 deletions Pipfile.lock

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions rethinkdb_mock/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ def do_run(self, sequence, test_for, arg, scope):

class ContainsFuncs(RBase):
def __init__(self, left, right, optargs={}):
assert(isinstance(right, MakeArray))
assert (isinstance(right, MakeArray))
self.left = left
self.right = right
self.optargs = optargs
Expand Down Expand Up @@ -797,7 +797,7 @@ def do_run(self, sequence, old_name, new_name, arg, scope):

class IndexDrop(BinExp):
def do_run(self, sequence, index_name, arg, scope):
assert(isinstance(self.left, RTable))
assert (isinstance(self.left, RTable))
current_db = self.find_db_scope()
current_table = self.find_table_scope()

Expand All @@ -810,7 +810,7 @@ def do_run(self, sequence, index_name, arg, scope):

class IndexList(MonExp):
def do_run(self, table, arg, scope):
assert(isinstance(self.left, RTable))
assert (isinstance(self.left, RTable))

current_db = self.find_db_scope()
current_table = self.find_table_scope()
Expand All @@ -822,27 +822,27 @@ def do_run(self, table, arg, scope):

class IndexWaitAll(MonExp):
def do_run(self, table, arg, scope):
assert(isinstance(self.left, RTable))
assert (isinstance(self.left, RTable))
return table


class IndexWaitOne(BinExp):
def do_run(self, table, index_name, arg, scope):
assert(isinstance(self.left, RTable))
assert (isinstance(self.left, RTable))
current_db = self.find_db_scope()
current_table = self.find_table_scope()
exists = arg.index_exists_in_table_in_db(
current_db,
current_table,
index_name
)
assert(exists)
assert (exists)
return table


class Sync(MonExp):
def do_run(self, table, arg, scope):
assert(isinstance(self.left, RTable))
assert (isinstance(self.left, RTable))
return table


Expand Down
12 changes: 6 additions & 6 deletions rethinkdb_mock/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def remove_array_elems_by_id(existing, to_remove):


def insert_into_table_with_conflict_setting(existing, to_insert, conflict):
assert(conflict in ('error', 'update', 'replace'))
assert (conflict in ('error', 'update', 'replace'))
existing_by_id = {row['id']: row for row in existing}
seen = set([])
result = []
Expand Down Expand Up @@ -114,7 +114,7 @@ def update_by_id(self, updated_rows):
return MockTableData(self.name, new_data, self.indexes), report

def insert(self, new_rows, conflict):
assert(conflict in ('error', 'update', 'replace'))
assert (conflict in ('error', 'update', 'replace'))
if not isinstance(new_rows, list):
new_rows = [new_rows]
new_data, report = insert_into_table_with_conflict_setting(self.rows, new_rows, conflict)
Expand Down Expand Up @@ -191,7 +191,7 @@ def get_table(self, table_name):
return self.tables_by_name[table_name]

def set_table(self, table_name, new_table_instance):
assert(isinstance(new_table_instance, MockTableData))
assert (isinstance(new_table_instance, MockTableData))
tables = util.obj_clone(self.tables_by_name)
tables[table_name] = new_table_instance
return MockDbData(tables)
Expand All @@ -205,7 +205,7 @@ def get_db(self, db_name):
return self.dbs_by_name[db_name]

def set_db(self, db_name, db_data_instance):
assert(isinstance(db_data_instance, MockDbData))
assert (isinstance(db_data_instance, MockDbData))
dbs_by_name = util.obj_clone(self.dbs_by_name)
dbs_by_name[db_name] = db_data_instance
return MockDb(dbs_by_name)
Expand Down Expand Up @@ -233,13 +233,13 @@ def list_dbs(self):
return list(self.dbs_by_name.keys())

def replace_table_in_db(self, db_name, table_name, table_data_instance):
assert(isinstance(table_data_instance, MockTableData))
assert (isinstance(table_data_instance, MockTableData))
db = self.get_db(db_name)
new_db = db.set_table(table_name, table_data_instance)
return self.set_db(db_name, new_db)

def insert_into_table_in_db(self, db_name, table_name, elem_list, conflict):
assert(conflict in ('error', 'update', 'replace'))
assert (conflict in ('error', 'update', 'replace'))
new_table_data, report = self.get_db(db_name).get_table(table_name).insert(elem_list, conflict)
return self._replace_table(db_name, table_name, new_table_data), report

Expand Down
8 changes: 4 additions & 4 deletions rethinkdb_mock/rql_rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def type_dispatch(rql_node):
@util.curry2
def handles_type(rql_type, func):
def handler(node):
assert(type(node) == rql_type)
assert (type(node) == rql_type)
return func(node)
RQL_TYPE_HANDLERS[rql_type] = handler
return handler
Expand Down Expand Up @@ -67,7 +67,7 @@ def handle_generic_binop_poly_2(mt_type_map, node):

@util.curry2
def handle_generic_ternop(Mt_Constructor, node):
assert(len(node._args) == 3)
assert (len(node._args) == 3)
return Mt_Constructor(*[type_dispatch(arg) for arg in node._args], optargs=process_optargs(node))


Expand Down Expand Up @@ -369,7 +369,7 @@ def plain_val_of_datum(datum_node):


def plain_list_of_make_array(make_array_instance):
assert(isinstance(make_array_instance, r_ast.MakeArray))
assert (isinstance(make_array_instance, r_ast.MakeArray))
return list(map(plain_val_of_datum, make_array_instance._args))


Expand Down Expand Up @@ -403,7 +403,7 @@ def handle_order_by(node):
right.append(mt_ast.Asc(type_dispatch(elem)))
else:
accepted = (r_ast.Desc, r_ast.Asc, r_ast.Func)
assert(elem.__class__ in accepted)
assert (elem.__class__ in accepted)
right.append(type_dispatch(elem))
if optargs.get("index"):
right.append(mt_ast.Asc(type_dispatch(r_ast.Datum(optargs["index"]))))
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Database",
"Topic :: Software Development :: Testing :: Mocking",
],
python_requires='>=3.7',
python_requires='>=3.8',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
)
16 changes: 8 additions & 8 deletions tests/functional/test_array_manip.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,19 @@ def test_nested(self, conn):
lambda doc: doc['data'].sample(3)
).run(conn)
result = list(result)
assert(len(result) == 1)
assert (len(result) == 1)
result = result[0]
assert(len(result) == 3)
assert (len(result) == 3)
for num in result:
assert(num <= 20)
assert(num >= 10)
assert (num <= 20)
assert (num >= 10)

def test_docs(self, conn):
result = r.db('db').table('things').sample(2).run(conn)
result = list(result)
assert(len(result) == 2)
assert (len(result) == 2)
doc1, doc2 = result
assert(doc1 != doc2)
assert (doc1 != doc2)
ids = set(['one', 'two', 'three'])
assert(doc1['id'] in ids)
assert(doc2['id'] in ids)
assert (doc1['id'] in ids)
assert (doc2['id'] in ids)
2 changes: 1 addition & 1 deletion tests/functional/test_distinct.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ def test_distinct_nested(self, conn):
for elem in result:
if isinstance(elem[0], dict):
for dict_elem in elem:
assert(ex2.has(dict_elem))
assert (ex2.has(dict_elem))
else:
assertEqual(ex1, set(elem))
30 changes: 15 additions & 15 deletions tests/functional/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,30 +112,30 @@ def get_data():

def test_random_0(self, conn):
result = r.random().run(conn)
assert(result <= 1)
assert(result >= 0)
assert(type(result) == float)
assert (result <= 1)
assert (result >= 0)
assert (type(result) == float)

def test_random_1(self, conn):
result = r.random(10).run(conn)
assert(result <= 10)
assert(result >= 0)
assert(type(result) == int)
assert (result <= 10)
assert (result >= 0)
assert (type(result) == int)

def test_random_1_float(self, conn):
result = r.random(10).run(conn)
assert(result <= 10)
assert(result >= 0)
assert(type(result) == int)
assert (result <= 10)
assert (result >= 0)
assert (type(result) == int)

def test_random_2(self, conn):
result = r.random(10, 20).run(conn)
assert(result <= 20)
assert(result >= 10)
assert(type(result) == int)
assert (result <= 20)
assert (result >= 10)
assert (type(result) == int)

def test_random_2_float(self, conn):
result = r.random(10, 20, float=True).run(conn)
assert(result <= 20)
assert(result >= 10)
assert(type(result) == float)
assert (result <= 20)
assert (result >= 10)
assert (type(result) == float)
4 changes: 2 additions & 2 deletions tests/functional/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_map_missing_field_no_default(self, conn):
).run(conn)
except RqlRuntimeError as e:
err = e
assert(isinstance(err, RqlRuntimeError))
assert (isinstance(err, RqlRuntimeError))


class TestBracket(MockTest):
Expand Down Expand Up @@ -498,4 +498,4 @@ def test_error1(self, conn):
except RqlRuntimeError as err:
rql_err = err
assertEqual('msg', err.message)
assert(isinstance(rql_err, RqlRuntimeError))
assert (isinstance(rql_err, RqlRuntimeError))
10 changes: 5 additions & 5 deletions tests/functional/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test_time_year_month_day_tz(self, conn):
assertEqual(2014, update_time.year)
assertEqual(6, update_time.month)
assertEqual(10, update_time.day)
assert(isinstance(update_time.tzinfo, RqlTzinfo))
assert (isinstance(update_time.tzinfo, RqlTzinfo))

def test_time_year_month_day_hour_minute_second_tz(self, conn):
r.db('unimportant').table('very').update({
Expand All @@ -147,7 +147,7 @@ def test_time_year_month_day_hour_minute_second_tz(self, conn):
assertEqual(15, update_time.hour)
assertEqual(30, update_time.minute)
assertEqual(45, update_time.second)
assert(isinstance(update_time.tzinfo, RqlTzinfo))
assert (isinstance(update_time.tzinfo, RqlTzinfo))

def test_error_with_less_than_4_args(self, conn):
try:
Expand All @@ -156,7 +156,7 @@ def test_error_with_less_than_4_args(self, conn):
}).run(conn)
except RqlCompileError as e:
err = e
assert('expected between 4 and 7' in err.message.lower())
assert ('expected between 4 and 7' in err.message.lower())

def test_error_with_no_timezone(self, conn):
date = datetime.datetime(2014, 3, 24, 12)
Expand All @@ -166,8 +166,8 @@ def test_error_with_no_timezone(self, conn):
}).run(conn)
except ReqlDriverCompileError as e:
err = e
assert('datetime' in err.message.lower())
assert('timezone' in err.message.lower())
assert ('datetime' in err.message.lower())
assert ('timezone' in err.message.lower())


class TestDuring(MockTest):
Expand Down
11 changes: 6 additions & 5 deletions tests/functional/test_update_insert_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_insert_one_no_id(self, conn):
result = list(result)
assertEqual(1, len(result))
joe = result[0]
assert(isinstance(joe['id'], text_type))
assert (isinstance(joe['id'], text_type))

def test_insert_array_no_ids(self, conn):
r.db('things').table('muppets').insert([
Expand All @@ -122,8 +122,8 @@ def test_insert_array_no_ids(self, conn):
}).run(conn)
result = list(result)
assertEqual(2, len(result))
assert(isinstance(result[0]['id'], text_type))
assert(isinstance(result[1]['id'], text_type))
assert (isinstance(result[0]['id'], text_type))
assert (isinstance(result[1]['id'], text_type))


class TestInsertDurability(MockTest):
Expand Down Expand Up @@ -422,7 +422,7 @@ def test_update_nonatomic_error(self, conn):
).run(conn)
except RqlRuntimeError as e:
err = e
assert(isinstance(err, RqlRuntimeError))
assert (isinstance(err, RqlRuntimeError))

def test_update_nonatomic_error_is_default(self, conn):
err = None
Expand All @@ -432,7 +432,8 @@ def test_update_nonatomic_error_is_default(self, conn):
).run(conn)
except RqlRuntimeError as e:
err = e
assert(isinstance(err, RqlRuntimeError))

assert (isinstance(err, RqlRuntimeError))


class TestUpdateReturnChanges(MockTest):
Expand Down

0 comments on commit db4764f

Please sign in to comment.