Skip to content

MockMan is a Python(Flask) project, used to create a mock local server which front end developers can use at time when backend is being parallelly developed or delayed.

Notifications You must be signed in to change notification settings

hemantTokopedia/MockMan

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

MockMan

MockMan is a Python(Flask) project, used to create a mock local server which front end developers can use at the time when the backend is being parallelly developed or delayed.

Pre Requisites

  • Python 3.7 or higher installed.
  • pip 10.0.1 or higher.

Installation

Clone the repository, open terminal and navigate to the root directory(where the run.py is)

python3 -m venv env
source env/bin/activate
pip3 install -r requirements.txt

Usage

To add new APIs Mock follow the following steps:

  • Open Project in any text editor which you are comfortable with(VS-Code, Sublime, PyCharm, etc.)

  • Add your response Mock JSON file to mocks. <MOCK_JSON_FILE_NAME.json>

    Add MOCK_JSON_FILE_NAME.json file

  • Go to the resources directory and create a new file with an appropriate name <File_Name.py>(Can be anything except the files already present in resources).

    Add File_Name.py file

  • Copy the following code to the newly created file and replace the <CLASS_NAME> with your class name and <MOCK_JSON_FILE_NAME.json> with your file name.

    from flask_restful import Resource
    from utility.FileHandler import FileHandler
    
    class CLASS_NAME(Resource):
        def get(self):
            return FileHandler.getJSONFrom("MOCK_JSON_FILE_NAME.json")

    Add code to File_Name.py

  • Go to app.py first import the newly added api class using the following syntax.

    from resources.<File_Name> import <Class_Name>
    

    add a new route by adding the endPoint.

    api.add_resource(HomeCards, '/v1/yourEndPoint')

    Add new route in app.py

  • Run the application by running the following command.

    python3 run.py

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

About

MockMan is a Python(Flask) project, used to create a mock local server which front end developers can use at time when backend is being parallelly developed or delayed.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%