Skip to content

Test driven development ["TDD"] of a Python module for Biblia API.

License

Notifications You must be signed in to change notification settings

dennislwm/pybiblia

Repository files navigation

pybiblia

Test driven development ["TDD"] of a Python module for Biblia API.

Project

Create a Python module that we can use to perform requests to Biblia API.

The CLI contains a subset of the module. The parameters are:

  1. Bible content
  2. Bible search
  3. Table of contents
  4. Verse of the day

Creating the Virtualenv

We'll start by cloning this repository to our workstation. Then, we'll install pipenv and create a Python 3 virtualenv for this project.

$ git clone https://github.com/dennislwm/pybiblia
$ cd pybiblia
$ pip3 install --user pipenv
$ pipenv --python $(which python3)

Configuring pybiblia

Before you can use pybiblia module, you need to obtain an API key. You can then pass the API key as a str parameter to class Pybiblia.

There are two options available to configure the API key if you're using the Biblia CLI. Choose either

  • set environment variable BIBLIA_API_KEY=<API_KEY>; or
  • create a config.json file and insert the line { "BIBLIA_API_KEY": "<API_KEY>" }.

Sign in at https://api.biblia.com/v1/Users/SignIn to register your application.


Project Structure

 pybiblia/                        <-- Root of your project
   |- .dockerignore               <-- Docker ignore
   |- .gitignore                  <-- GitHub ignore
   |- Dockerfile
   |- LICENSE 
   |- Makefile                    <-- Make 
   |- Pipfile                     <-- Generated by pipenv
   |- Pipfile.lock
   |- README.md                   <-- GitHub README markdown 
   |- requirements.txt            <-- Python requirements used by Dockerfile
   +- src/
      +- pybiblia/                <-- Holds any business logic
         |- __init__.py
         |- cli.py                <-- Python module to parse command line
         |- pybiblia.py           <-- Python module to requests 
   +- tests/                      <-- Holds any automated tests
      |- test_cli.py              <-- Python script to test cli.py
      |- test_pybiblia.py

Test Driven Development

For this project, we're using pytest as our testing framework. We wrote a line in our Makefile that utilizes the pytest.

The file test_cli.py ensures that our CLI works as expected.

The file test_pybiblia.py ensures that our requests to Biblia API works as expected.

Usage

Workstation

Before we can use pybiblia in our Python development, we need to activate virtualenv and install our package locally.

$ pipenv shell
(pybiblia) $ pip install -e .

To uninstall our package.

(pybiblia) $ pip uninstall pybiblia

Production

We need to install using pip install pybiblia and then we can add the line import pybiblia in our Python script.

About

Test driven development ["TDD"] of a Python module for Biblia API.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published