Skip to content

Commit

Permalink
Merge pull request #166 from fauna/fix-ci
Browse files Browse the repository at this point in the history
Add circleci config
  • Loading branch information
Trevor Sibanda authored Nov 2, 2020
2 parents 63e7df8 + c561f0f commit ac21702
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 7 deletions.
129 changes: 129 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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:<<parameters.python_version>>

- image: gcr.io/faunadb-cloud/faunadb/enterprise/<<parameters.version>>: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
2 changes: 1 addition & 1 deletion tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}))
Expand Down
14 changes: 8 additions & 6 deletions tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit ac21702

Please sign in to comment.