/CatalogManager

RESTful APIs to manage product inventory with CRUD operations and different testcases

Primary LanguagePython

Introduction

This is set of RESTful APIs with Django Rest Framework(DRF) for managing product catalog. The API provides:

  • Creating, updating, listing and deleting products
  • Searching for products
  • Uploading product image
  • Tests to check if the API are working correctly

Installation and setup

  1. Clone the repository
    git clone https://github.com/sonaljain067/CatalogManager.git

  2. Create a virtual environment
    cd CatalogMaster
    python3 -m venv env or virtualenv env
    to create virtual environment named env

  3. Activate the virtual environment
    In Ubuntu: source env/bin/activate
    In Windows: .\env\Scripts\activate

  4. Install dependencies
    pip install -r requirements.txt

  5. Setup database
    python manage.py migrate or python3 manage.py migrate

  6. Create a superuser
    python manage.py createsuperuser or python3 manage.py createsuperuser

  7. Run the server
    python manage.py runserver or python3 manage.py runserver

API Endpoints

GET /api/product/ - Retrives all products
POST /api/product/create - Create a new product
PUT /api//product/<id> - Update an existing product
DELETE /api/product/<id> - Delete an existing product

Test Cases

  1. Test that API returns a list of products when no search is provided.
  2. Test that API returns a list of products when search is provided
  3. Test that API return a empty list when search is not
  4. Test that API create a product with only valid payload
  5. Test that API doesn't create product with invalid payload
  6. Test that API update a product with only valid payload
  7. Test that API doesn't create product with invalid payload
  8. Test that API delete a existing product

Running Tests

To test the test suite, run the command:
python manage.py test or python3 manage.py test
This will run all the tests in tests.py file

API Documentation

The Catalog Manager API is documented using Postman. You can import the Postman Collection to get started.