Skip to content

Commit

Permalink
Run tests on ci (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
birnbaum authored Nov 20, 2018
1 parent 1e9daab commit 8dcb101
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ language: python
python:
- "3.5"

before_install:
- openssl aes-256-cbc -K $encrypted_b8e3bf9ce0e9_key -iv $encrypted_b8e3bf9ce0e9_iv -in .travis/service-account-key.json.enc -out $HOME/service-account-key.json -d
- export GOOGLE_APPLICATION_CREDENTIALS=$HOME/service-account-key.json
- export TEST_BUCKET=othoz-gcsfs-tests

install:
- pip install pipenv
- pipenv install --dev --three

script:
- flake8
# - pytest --cov=fs_gcsfs --cov-branch --cov-report=xml TODO: Find a way to run the tests without accessing an actual bucket
- pytest --cov=fs_gcsfs --cov-branch --cov-report=xml --numprocesses=16

deploy:
provider: pypi
Expand Down
Binary file added .travis/service-account-key.json.enc
Binary file not shown.
20 changes: 18 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,27 @@ and run the following from the root directory of the project::

$ pipenv install --dev --three

This will create a virtualenv with all packages and dev-packages installed. Now you can, for example,
run all tests via::
This will create a virtualenv with all packages and dev-packages installed.


Tests
-----
All CI tests run against an actual GCS bucket provided by `Othoz <http://othoz.com/>`__. In order to run the tests against your own bucket,
make sure to set up a `Service Account <https://cloud.google.com/iam/docs/service-accounts>`__ with all necessary permissions:

- storage.buckets.get
- storage.objects.get
- storage.objects.list
- storage.objects.create
- storage.objects.update
- storage.objects.delete

Expose your bucket name as an environment variable ``$TEST_BUCKET`` and run the tests via::

$ pipenv run pytest

Note that the tests mostly wait for I/O, therefore it makes sense to highly parallelize them with `xdist <https://github.com/pytest-dev/pytest-xdist>`__.


Credits
-------
Expand Down
3 changes: 2 additions & 1 deletion fs_gcsfs/tests/test_gcsfs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
import uuid
import os

import pytest
from fs.errors import IllegalBackReference
Expand All @@ -8,7 +9,7 @@

from fs_gcsfs import GCSFS

TEST_BUCKET = "othoz-test"
TEST_BUCKET = os.environ['TEST_BUCKET']


class TestGCSFS(FSTestCases, unittest.TestCase):
Expand Down

0 comments on commit 8dcb101

Please sign in to comment.