Code Monkey home page Code Monkey logo

testcase's Introduction

Vagrant + Flask + Ansible testcase repository

This repository contains ready-to-use set of Vagrantfile, web-application, described in task, tests to it and two Ansible roles, that will install MongoDB to virtual machine and start an application.

There no crypted variables, so you don't need to use vault_pass file for using Ansible roles.

Ansible roles design overview

Each role has few directories:

  • tasks - Directory with main.yml file, which contains main installation tasks;
  • defaults - Directory contains .yml file with variables;
  • handlers - Directory contains file with handlers description;
  • files - Directory contains files that should be copied to virtual machine

If you need to use Ansible roles without Vagrantfile, move to "provsioning" directory, set correct IP-address to inventory and use the following command:

ansible-playbook playbook.yml -i inventory tags=mongodb, flaskapp

If you need to run only one role - use appreciate tag.

NOTE. You must have pre-installed Ansible version 1.6 or later to use these roles

Flask application overview

This is a small Flask application, that listens port 8080, with two endpoints:

  • http://ip-address:8080/post - recieves only POST requests with JSON payload like {'uid': '1', 'name': 'John Doe', 'date': '2015-05-12T14:36:00.451765', 'md5checksum': 'e8c83e232b64ce94fdd0e4539ad0d44f'} and checks MD5 checksum of uid, name and date fields. If checksum is correct - it saves data to MongoDB database.
  • http://ip-address:8080/get - recieves only GET request with the simillar JSON payload, but with only two fields - uid and data. For given parameters it will return number of occurences of a given UID (John Doe) for that day.

For using application you must have pre-installed Python version 2.7 or later, virtualenv, Flask and Flask extension library - Flask-PyMongo.

NOTE. TCP port 8080 should be opened and free before starting application in order to allow it receiving requests.

To run application use the following commands:

cd "application_folder" 
virtualenv venv
python flaskapp.py

Application tests overview

There are 4 unit-test - 2 for each endpoint. For each endpoint there is one test with correct data and one with incorrect. Tests are waiting for correct application responses.

To run tests use the following commands:

cd "application_folder" 
python app_tests.py

Author information

Created in 2015 by Paul Yehorov. email: [email protected]

testcase's People

Watchers

James Cloos avatar Pavlo 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.