Software Testings


Types

Consider the following graph, each node is a function,

A

B

C

D

Example

tests

src

app

app.py

test_app.py


from flask_jsonpify import jsonpify
from flask import Flask, request

app = Flask(__name__)

@app.route("/")
def home():
    return jsonpify({'output':'Hello World'})

if __name__ == "__main__":
    app.run()
    
export PYTHONPATH=src

from app import *
import unittest
import json

def test_home():
    assert home.__name__=='home'

class MyAppCase(unittest.TestCase):
    def setUp(self):
        app.config['TESTING'] = True
        self.app = app.test_client()
    def test_home(self):
        resp = self.app.get('/')
        data = json.loads(resp.get_data(as_text=True))
        self.assertEqual(data['output'],'Hello World')
    

In your app folder, run pytest.

References


  1. Deploying Flask app on Heroku using GitHub
  2. Heroku free account limited?
  3. https://devcenter.heroku.com/articles/getting-started-with-nodejs#provision-a-database
  4. Creating CI/CD Pipeline using GitHub Actions for Python Project (Heroku Deployment Example)
  5. Introduction to Heroku