Coder Social home page Coder Social logo

google_drive_api's Introduction

Tests for Google Drive API

This project contains code all types of tests for testing file download from google drive to local folder using google drive api

Project Structure Overview

|-- 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

Steps to Run the project-

  1. Install Docker:

  2. Clone this repo and traverse to project directory

$ cd GOOGLE_DRIVE_API
  1. Build and start the container using -
$ docker-compose up

  1. Check the running container status using
$ docker ps

To trigger download using drive-api:

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

To run tests:

$ 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

To view test run report:

Go to url http://localhost:4040

Testing Approach

  • 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 and patching is done to isolate functions under test and generate error scenarios.

  • Test Data is provided to the tests using a mix of hardcode values, faker

  • json schema validation is implemented for api tests.

  • The project uses file conftest.py to share test data in the form of test fixtures and configuration among all the tests.

  • All the test run reports are stored a reports folder which is being pinged by the allure-report service continuously where the reports can be seen along with the previous history

  • Keeping Continuous Integration and Testing in mind, entire project is dockerized. The docker containers can be configured to be spawned using tools like jenkins on code change to run tests.

  • The test implementes following features as well:

Future Tasks-

  • Add more tests of each category.
  • Divide tests into categories like unit, functional

google_drive_api's People

Contributors

shashikumarraja avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.