From 410129ede32d02e15eec10872836188a338bbf8e Mon Sep 17 00:00:00 2001 From: Trevor Sibanda Date: Wed, 28 Oct 2020 20:00:44 +0200 Subject: [PATCH 1/2] Add circleci config --- .circleci/config.yml | 129 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..ae9b7b81 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,129 @@ +version: 2.1 +description: FaunaDB Python Driver Tests + +executors: + core: + parameters: + python_version: + type: string + version: + type: enum + enum: ["stable", "nightly"] + resource_class: large + docker: + - image: circleci/python:<> + + - image: gcr.io/faunadb-cloud/faunadb/enterprise/<>:latest + name: core + auth: + username: _json_key + password: $GCR_KEY + + environment: + FAUNA_ENDPOINT: http://core:8443 + FAUNA_ROOT_KEY: secret + FAUNA_DOMAIN: core + FAUNA_SCHEME: http + FAUNA_PORT: 8443 + +commands: + build_and_test: + description: "Run Python tests" + steps: + - checkout + + - run: + name: Install codecov + command: | + sudo pip install codecov + + - run: + name: Wait FaunaDB init + command: | + while ! $(curl --output /dev/null --silent --fail --max-time 1 http://core:8443/ping); do sleep 1; done + + - run: + name: Run Tests + command: | + mkdir results + coverage run setup.py test 2>&1 | tee log.txt + + - run: + name: Gather Results + when: always + command: | + mkdir -p results/ + mv log.txt results/log.txt + + - store_test_results: + path: results/ + + - store_artifacts: + path: results/ + destination: tr1 + +jobs: + core-stable-38: + executor: + name: core + python_version: "3.8" + version: stable + steps: + - build_and_test + + core-nightly-38: + executor: + name: core + python_version: "3.8" + version: nightly + steps: + - build_and_test + + core-stable-34: + executor: + name: core + python_version: "3.4" + version: stable + steps: + - build_and_test + + core-nightly-34: + executor: + name: core + python_version: "3.4" + version: nightly + steps: + - build_and_test + + core-stable-27: + executor: + name: core + python_version: "2.7" + version: stable + steps: + - build_and_test + + core-nightly-27: + executor: + name: core + python_version: "2.7" + version: nightly + steps: + - build_and_test + +workflows: + version: 2 + build_and_test: + jobs: + - core-stable-38: + context: faunadb-drivers + - core-nightly-38: + context: faunadb-drivers + - core-stable-34: + context: faunadb-drivers + - core-nightly-34: + context: faunadb-drivers + - core-stable-27: + context: faunadb-drivers + - core-nightly-27: + context: faunadb-drivers From c561f0ffd3976b8641ffa01b38af239d5661196f Mon Sep 17 00:00:00 2001 From: Trevor Sibanda Date: Thu, 29 Oct 2020 12:43:37 +0200 Subject: [PATCH 2/2] Fix failing tests --- tests/test_errors.py | 2 +- tests/test_query.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/test_errors.py b/tests/test_errors.py index c8997350..c6e9a30a 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -100,7 +100,7 @@ def test_instance_not_found(self): "instance not found") def test_value_not_found(self): - self._assert_query_error(query.select("a", {}), NotFound, "value not found") + self._assert_query_error(query.select("a", {}), NotFound, "value not found", ["from"]) def test_instance_already_exists(self): self.client.query(create_collection({"name": "duplicates"})) diff --git a/tests/test_query.py b/tests/test_query.py index de16c54b..f26237c1 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -1059,7 +1059,10 @@ def test_to_string(self): self.assertEqual(self._q(query.to_string(42)), "42") def test_to_array(self): - self.assertEqual(self._q(query.to_array({'x':0,'y':1})), [['x',0], ['y', 1]]) + arr = self._q(query.to_array({'x': 0, 'y': 1})) + self.assertEquals(len(arr), 2) + self.assertIn(['x',0], arr) + self.assertIn(['y', 1], arr) self._assert_bad_query(query.to_array(23)) def test_to_object(self): @@ -1183,14 +1186,13 @@ def test_nested_keys(self): "role": "admin" })) - self.assertEqual( - client.query(query.paginate(query.keys()))["data"], - [server_key["ref"], admin_key["ref"]] - ) + server_key_ref = Ref(server_key["ref"].id(), cls=Ref("keys", db=Ref("db-for-keys", cls=Native.DATABASES))) + admin_key_ref = Ref(admin_key["ref"].id(), cls=Ref( + "keys", db=Ref("db-for-keys", cls=Native.DATABASES))) self.assertEqual( self.admin_client.query(query.paginate(query.keys(query.database("db-for-keys"))))["data"], - [server_key["ref"], admin_key["ref"]] + [server_key_ref, admin_key_ref] ) def create_new_database(self, client, name):