This project contains code all types of tests for testing file download from google drive to local folder using google drive api
|-- root(google_drive_api)
|-- [+] src # main app code is here
|-- [+] tests # tests are here
|-- test_drive_api.py
|-- test_credentials.py
|-- test_utils
|-- [+] htmlcov # contains coverage report
|-- [+] reports # contains test report
|-- [+] schemas # response json schema
|-- conftest.py # shares test fixtures
|-- pytest.ini # basic test configs
|-- requirements.txt # all app dependencies
|-- docker-compose.yml # to spawn containers
|-- dockerfile # docker build file
-
Install
Docker
: -
Clone this repo and traverse to project directory
$ cd GOOGLE_DRIVE_API
- Build and start the container using -
$ docker-compose up
- Check the running container status using
$ docker ps
Pre-requisite- Google oauth2.0
credentials
and token
file are required
to proceed further.
Make sure to obtain those files first and then pass their path as environment variable while executing below command
$ docker exec -ti google-drive-api token_path='/path/to/token.pickle' secret_path='/path/to/credentials.json' download_path='/path/to/download/folder/' python /google_drive_api/src/drive_api.py
$ docker exec -ti google-drive-api pytest /google_drive_api/tests/test_utils.py
$ docker exec -ti google-drive-api pytest /google_drive_api/tests/test_drive_api.py
$ docker exec -ti google-drive-api pytest /google_drive_api/tests/test_credentials.py
Go to url http://localhost:4040
-
The project has different types of tests written using
pytest
, a python based test framework. -
All the tests are written as mix of unit and integration covering the functional aspects of each module.
-
Use of
mocking
andpatching
is done to isolate functions under test and generate error scenarios. -
Test Data
is provided to the tests using a mix ofhardcode values
,faker
-
json schema validation
is implemented for api tests. -
The project uses file
conftest.py
to sharetest data
in the form oftest fixtures
andconfiguration
among all the tests. -
All the test run reports are stored a
reports
folder which is being pinged by theallure-report
service continuously where the reports can be seen along with the previous history -
Keeping
Continuous Integration and Testing
in mind, entire project isdockerized
. The docker containers can be configured to be spawned using tools likejenkins
on code change to run tests. -
The test implementes following features as well:
-
pytest-xdist
to support parallel runs -
code coverage
report -
flaky
support to re-run tests n-times on failure
-
- Add more tests of each category.
- Divide tests into categories like unit, functional