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.
- Python 3.7 or higher installed.
- pip 10.0.1 or higher.
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
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>
-
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 inresources
). -
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")
-
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')
-
Run the application by running the following command.
python3 run.py
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.