diff --git a/.github/workflows/yapf.yml b/.github/workflows/yapf.yml index 16628bfc..8910966c 100644 --- a/.github/workflows/yapf.yml +++ b/.github/workflows/yapf.yml @@ -22,7 +22,7 @@ jobs: cache: pip - name: Install yapf - run: pip install yapf + run: pip install yapf==0.40.1 - name: Check Format run: | diff --git a/README.rst b/README.rst index faf20c35..e4a1ff1d 100644 --- a/README.rst +++ b/README.rst @@ -172,7 +172,7 @@ If you want to run fauna, then run integration tests separately: .. code-block:: bash - $ make docker-fauna + $ make run-fauna $ source venv/bin/activate $ make install $ make integration-test diff --git a/fauna/__init__.py b/fauna/__init__.py index 58e0e8b1..f3ec111a 100644 --- a/fauna/__init__.py +++ b/fauna/__init__.py @@ -1,5 +1,5 @@ __title__ = "Fauna" -__version__ = "0.7.0" +__version__ = "0.7.1" __api_version__ = "10" __author__ = "Fauna, Inc" __license__ = "MPL 2.0" diff --git a/fauna/client/client.py b/fauna/client/client.py index a198d542..b5550bc6 100644 --- a/fauna/client/client.py +++ b/fauna/client/client.py @@ -86,7 +86,7 @@ def __init__( self._query_tags.update(query_tags) if query_timeout is not None: - self._query_timeout_ms = query_timeout.total_seconds() * 1000 + self._query_timeout_ms = int(query_timeout.total_seconds() * 1000) else: self._query_timeout_ms = None diff --git a/setup.py b/setup.py index 9f79f861..2daa2180 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ ] extras_require = { - "lint": ["yapf==0.32.0"], + "lint": ["yapf==0.40.1"], "test": [ "pytest==7.3.0", "pytest-env==0.8.1", "pytest-cov==4.0.0", "pytest-httpx==0.21.3", "pytest-subtests==0.10.0" diff --git a/tests/integration/test_client.py b/tests/integration/test_client.py index fdf46a75..0b2ec958 100644 --- a/tests/integration/test_client.py +++ b/tests/integration/test_client.py @@ -1,4 +1,6 @@ +from datetime import timedelta import pytest +from fauna.client.client import QueryOptions from fauna.errors import ClientError @@ -27,3 +29,11 @@ def test_handle_invalid_json_response(): with pytest.raises(ClientError, match=err_msg): c = Client(endpoint="https://dashboard.fauna.com/") c.query(fql("'foolery'")) + + +def test_fauna_accepts_query_timeout_header(): + c1 = Client(query_timeout=timedelta(seconds=5)) + c1.query(fql('"hello"')) + + c2 = Client() + c2.query(fql('"hello"'), QueryOptions(query_timeout=timedelta(seconds=5))) diff --git a/tests/integration/test_query.py b/tests/integration/test_query.py index 487b8ea6..04ada6c6 100644 --- a/tests/integration/test_query.py +++ b/tests/integration/test_query.py @@ -27,23 +27,28 @@ def test_query_smoke_test(subtests, client): def test_query_with_all_stats(client, a_collection): res = client.query(fql("${col}.create({})", col=a_collection)) + doc_id = res.data.id + res = client.query( + fql("${col}.create({})\n${col}.byId(${id})", + col=a_collection, + id=doc_id)) assert res.stats.compute_ops > 0 assert res.stats.read_ops > 0 assert res.stats.write_ops > 0 assert res.stats.storage_bytes_read > 0 assert res.stats.storage_bytes_write > 0 assert res.stats.query_time_ms > 0 - assert res.stats.contention_retries >= 0 + assert res.stats.contention_retries == 0 def test_query_with_constraint_failure(client): with pytest.raises(QueryRuntimeError) as e: client.query( - fql('Function.create({"name": "double", "body": "x => x * 2"})')) + fql('Function.create({"name": "false", "body": "_ => false"})')) assert e.value.constraint_failures == [ ConstraintFailure( - message="The identifier `double` is reserved.", + message="The identifier `false` is reserved.", name=None, paths=[["name"]], ),