diff --git a/django-mongo/README.md b/django-mongo/README.md new file mode 100644 index 0000000..ea2afb3 --- /dev/null +++ b/django-mongo/README.md @@ -0,0 +1,92 @@ +# Inventory Management Application + +## Overview + +A simple Django + MongoDB inventory management application using mongoengine and Django REST Framework to test Keploy integration capabilities using Django and MongoDB. +The endpoints available will be: + +1. `GET /api/items/` - List all items +2. `POST /api/items/` - Create a new item +3. `GET /api/items//` - Retrieve an item by ID +4. `PUT /api/items//` - Update an item by ID +5. `DELETE /api/items//` - Delete an item by ID + +## Requirements + +- Python 3.x +- Django +- mongoengine +- djangorestframework + +## Setup Instructions + +1. Clone the repository and navigate to project directory. + ```bash + git clone https://github.com/keploy/samples-python.git + cd samples-python/django-mongo/django_mongo + ``` +2. Install Keploy. + ```bash + curl --silent -O -L https://keploy.io/install.sh && source install.sh + ``` +3. Start MongoDB instance. + ```bash + docker pull mongo + docker run --name mongodb -d -p 27017:27017 -v mongo_data:/data/db -e MONGO_INITDB_ROOT_USERNAME= -e MONGO_INITDB_ROOT_PASSWORD= mongo + ``` +4. Set up Django appllication. + ```bash + python3 -m virtualenv venv + source venv/bin/activate + pip3 install -r requirements.txt + ``` +5. Capture the testcases. + ```bash + keploy record -c "python3 manage.py runserver" + ``` +6. Generate testcases by making API calls. + ```bash + # List items + # GET /api/items/ + curl -X GET http://localhost:8000/api/items/ + ``` + ```bash + # Create Item + # POST /api/items/ + curl -X POST http://localhost:8000/api/items/ \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Gadget C", + "quantity": 200, + "description": "A versatile gadget with numerous features." + }' + ``` + ```bash + # Retrieve Item + # GET /api/items// + curl -X GET http://localhost:8000/api/items// + ``` + ```bash + # Update Item + # PUT /api/items// + curl -X PUT http://localhost:8000/api/items/6142d21e122bda15f6f87b1d/ \ + -H "Content-Type: application/json" \ + -d '{ + "name": "Updated Widget A", + "quantity": 120, + "description": "An updated description for Widget A." + }' + ``` + ```bash + # Delete Item + # DELETE /api/items// + curl -X DELETE http://localhost:8000/api/items// + ``` + Replace `` with the actual ID of the item you want to retrieve, update, or delete. + +## Run the testcases + +Shut down MongoDB, Keploy doesn't need it during tests. +```bash +keploy test -c "python3 manage.py runserver" --delay 10 +``` \ No newline at end of file diff --git a/django-mongo/django_mongo/django_mongo/__init__.py b/django-mongo/django_mongo/django_mongo/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django-mongo/django_mongo/django_mongo/asgi.py b/django-mongo/django_mongo/django_mongo/asgi.py new file mode 100644 index 0000000..0f6b170 --- /dev/null +++ b/django-mongo/django_mongo/django_mongo/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for django_mongo project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_mongo.settings') + +application = get_asgi_application() diff --git a/django-mongo/django_mongo/django_mongo/settings.py b/django-mongo/django_mongo/django_mongo/settings.py new file mode 100644 index 0000000..3ade7c6 --- /dev/null +++ b/django-mongo/django_mongo/django_mongo/settings.py @@ -0,0 +1,148 @@ +""" +Django settings for django_mongo project. + +Generated by 'django-admin startproject' using Django 5.1.2. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.1/ref/settings/ +""" + +from pathlib import Path +import mongoengine + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-3g@-x5(3t(i(p^qnu9lz3hk1u1yobrvwz($5^ucvnn0a6b$%ob' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'rest_framework', + 'inventory', +] + +REST_FRAMEWORK = { + 'DEFAULT_PERMISSION_CLASSES': [ + 'rest_framework.permissions.AllowAny', + ], +} + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'django_mongo.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'django_mongo.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases + +# DATABASES = { +# 'default': { +# 'ENGINE': 'django.db.backends.sqlite3', +# 'NAME': BASE_DIR / 'db.sqlite3', +# } +# } + + +# Password validation +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.1/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +# MongoDB configuration +MONGO_DB_NAME = 'inventory_db' +MONGO_USER = 'admin' +MONGO_PASSWORD = 'admin' +MONGO_HOST = 'localhost' +MONGO_PORT = 27017 + +# Connect to MongoDB +mongoengine.connect( + db=MONGO_DB_NAME, + username=MONGO_USER, + password=MONGO_PASSWORD, + host=MONGO_HOST, + port=MONGO_PORT +) \ No newline at end of file diff --git a/django-mongo/django_mongo/django_mongo/urls.py b/django-mongo/django_mongo/django_mongo/urls.py new file mode 100644 index 0000000..81af1ac --- /dev/null +++ b/django-mongo/django_mongo/django_mongo/urls.py @@ -0,0 +1,23 @@ +""" +URL configuration for django_mongo project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('api/', include('inventory.urls')), +] diff --git a/django-mongo/django_mongo/django_mongo/wsgi.py b/django-mongo/django_mongo/django_mongo/wsgi.py new file mode 100644 index 0000000..a13bfdb --- /dev/null +++ b/django-mongo/django_mongo/django_mongo/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for django_mongo project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_mongo.settings') + +application = get_wsgi_application() diff --git a/django-mongo/django_mongo/inventory/__init__.py b/django-mongo/django_mongo/inventory/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django-mongo/django_mongo/inventory/admin.py b/django-mongo/django_mongo/inventory/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/django-mongo/django_mongo/inventory/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/django-mongo/django_mongo/inventory/apps.py b/django-mongo/django_mongo/inventory/apps.py new file mode 100644 index 0000000..905749f --- /dev/null +++ b/django-mongo/django_mongo/inventory/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class InventoryConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'inventory' diff --git a/django-mongo/django_mongo/inventory/migrations/__init__.py b/django-mongo/django_mongo/inventory/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django-mongo/django_mongo/inventory/models.py b/django-mongo/django_mongo/inventory/models.py new file mode 100644 index 0000000..02dd773 --- /dev/null +++ b/django-mongo/django_mongo/inventory/models.py @@ -0,0 +1,7 @@ +from django.db import models +from mongoengine import Document, StringField, IntField + +class Item(Document): + name = StringField(required=True) + quantity = IntField(required=True) + description = StringField() \ No newline at end of file diff --git a/django-mongo/django_mongo/inventory/serializers.py b/django-mongo/django_mongo/inventory/serializers.py new file mode 100644 index 0000000..a178995 --- /dev/null +++ b/django-mongo/django_mongo/inventory/serializers.py @@ -0,0 +1,18 @@ +from rest_framework import serializers +from .models import Item + +class ItemSerializer(serializers.Serializer): + id = serializers.CharField(read_only=True) + name = serializers.CharField(required=True) + quantity = serializers.IntegerField(required=True) + description = serializers.CharField(required=False) + + def create(self, validated_data): + return Item(**validated_data).save() + + def update(self, instance, validated_data): + instance.name = validated_data.get('name', instance.name) + instance.quantity = validated_data.get('quantity', instance.quantity) + instance.description = validated_data.get('description', instance.description) + instance.save() + return instance diff --git a/django-mongo/django_mongo/inventory/tests.py b/django-mongo/django_mongo/inventory/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/django-mongo/django_mongo/inventory/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/django-mongo/django_mongo/inventory/urls.py b/django-mongo/django_mongo/inventory/urls.py new file mode 100644 index 0000000..f35e225 --- /dev/null +++ b/django-mongo/django_mongo/inventory/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from .views import ItemViewSet + +urlpatterns = [ + path('items/', ItemViewSet.as_view({'get': 'list', 'post': 'create'})), + path('items//', ItemViewSet.as_view({'get': 'retrieve', 'put': 'update', 'delete': 'destroy'})), +] \ No newline at end of file diff --git a/django-mongo/django_mongo/inventory/views.py b/django-mongo/django_mongo/inventory/views.py new file mode 100644 index 0000000..6974df7 --- /dev/null +++ b/django-mongo/django_mongo/inventory/views.py @@ -0,0 +1,49 @@ +from django.shortcuts import render +from rest_framework import viewsets +from rest_framework.response import Response +from rest_framework import status +from .models import Item +from .serializers import ItemSerializer + +class ItemViewSet(viewsets.ViewSet): + + def list(self, request): + items = Item.objects.all() + serializer = ItemSerializer(items, many=True) + return Response(serializer.data) + + def create(self, request): + serializer = ItemSerializer(data=request.data) + if serializer.is_valid(): + item = Item(**serializer.validated_data) + item.save() + return Response(serializer.data, status=status.HTTP_201_CREATED) + return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) + + def retrieve(self, request, pk=None): + try: + item = Item.objects.get(id=pk) + serializer = ItemSerializer(item) + return Response(serializer.data) + except Item.DoesNotExist: + return Response(status=status.HTTP_404_NOT_FOUND) + + def update(self, request, pk=None): + try: + item = Item.objects.get(id=pk) + serializer = ItemSerializer(item, data=request.data) + if serializer.is_valid(): + updated_item = serializer.save() # This will call the update method + return Response(ItemSerializer(updated_item).data) # Serialize the updated item + return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) + except Item.DoesNotExist: + return Response(status=status.HTTP_404_NOT_FOUND) + + + def destroy(self, request, pk=None): + try: + item = Item.objects.get(id=pk) + item.delete() + return Response(status=status.HTTP_204_NO_CONTENT) + except Item.DoesNotExist: + return Response(status=status.HTTP_404_NOT_FOUND) \ No newline at end of file diff --git a/django-mongo/django_mongo/keploy.yml b/django-mongo/django_mongo/keploy.yml new file mode 100755 index 0000000..481f26f --- /dev/null +++ b/django-mongo/django_mongo/keploy.yml @@ -0,0 +1,61 @@ +path: "" +appId: 0 +appName: django_mongo +command: python3 manage.py runserver +templatize: + testSets: [] +port: 0 +dnsPort: 26789 +proxyPort: 16789 +debug: false +disableTele: false +disableANSI: false +containerName: "" +networkName: "" +buildDelay: 30 +test: + selectedTests: {} + globalNoise: + global: {} + test-sets: {} + delay: 5 + host: "" + port: 0 + apiTimeout: 5 + skipCoverage: false + coverageReportPath: "" + ignoreOrdering: true + mongoPassword: default@123 + language: "" + removeUnusedMocks: false + fallBackOnMiss: false + jacocoAgentPath: "" + basePath: "" + mocking: true + ignoredTests: {} + disableLineCoverage: false + disableMockUpload: true + useLocalMock: false + updateTemplate: false +record: + filters: [] + recordTimer: 0s +configPath: "" +bypassRules: [] +generateGithubActions: false +keployContainer: keploy-v2 +keployNetwork: keploy-network +cmdType: native +contract: + services: [] + tests: [] + path: "" + download: false + generate: false + driven: consumer + mappings: + servicesMapping: {} + self: "" +inCi: false + +# Visit [https://keploy.io/docs/running-keploy/configuration-file/] to learn about using keploy through configration file. diff --git a/django-mongo/django_mongo/keploy/test-set-0/mocks.yaml b/django-mongo/django_mongo/keploy/test-set-0/mocks.yaml new file mode 100755 index 0000000..50d9642 --- /dev/null +++ b/django-mongo/django_mongo/keploy/test-set-0/mocks.yaml @@ -0,0 +1,490 @@ +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-0 +spec: + metadata: + operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "PyMongo|c|MongoEngine","version": "4.10.1|0.29.1"},"os": {"type": "Linux","name": "Linux","architecture": "x86_64","version": "6.5.0-1025-azure"},"platform": "CPython 3.12.1.final.0","env": {"container": {"runtime": "docker"}}}}, returnFieldsSelector: }' + type: config + requests: + - header: + length: 332 + requestId: 1804289383 + responseTo: 0 + Opcode: 2004 + message: + flags: 0 + collection_name: admin.$cmd + number_to_skip: 0 + number_to_return: -1 + query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"PyMongo|c|MongoEngine","version":"4.10.1|0.29.1"},"os":{"type":"Linux","name":"Linux","architecture":"x86_64","version":"6.5.0-1025-azure"},"platform":"CPython 3.12.1.final.0","env":{"container":{"runtime":"docker"}}}}' + return_fields_selector: "" + responses: + - header: + length: 329 + requestId: 125 + responseTo: 1804289383 + Opcode: 1 + message: + response_flags: 8 + cursor_id: 0 + starting_from: 0 + number_returned: 1 + documents: + - '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"6713fe1e569046d9af25b0b5"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1729364654276"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"20"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"25"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}' + read_delay: 640736 + created: 1729364654 + reqTimestampMock: 2024-10-19T19:04:14.276667841Z + resTimestampMock: 2024-10-19T19:04:14.277439441Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-1 +spec: + metadata: + operation: '{ OpMsg flags: 65536, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"topologyVersion":{"processId":{"$oid":"6713fe1e569046d9af25b0b5"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberInt":"10000"},"$db":"admin"} }], checksum: 0 }' + type: config + requests: + - header: + length: 134 + requestId: 846930886 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 65536 + sections: + - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"topologyVersion":{"processId":{"$oid":"6713fe1e569046d9af25b0b5"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberInt":"10000"},"$db":"admin"} }' + checksum: 0 + read_delay: 1789950 + responses: + - header: + length: 313 + requestId: 129 + responseTo: 846930886 + Opcode: 2013 + message: + flagBits: 2 + sections: + - '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"6713fe1e569046d9af25b0b5"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1729364664289"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"20"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"25"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 10010192973 + created: 1729364664 + reqTimestampMock: 2024-10-19T19:04:14.279291948Z + resTimestampMock: 2024-10-19T19:04:24.289653646Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-2 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"$db":"admin"} }], checksum: 0 }' + type: config + requests: + - header: + length: 52 + requestId: 1714636915 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"$db":"admin"} }' + checksum: 0 + read_delay: 10002211829 + responses: + - header: + length: 313 + requestId: 130 + responseTo: 1714636915 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"6713fe1e569046d9af25b0b5"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1729364664291"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"21"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"25"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 238677 + created: 1729364664 + reqTimestampMock: 2024-10-19T19:04:24.291808444Z + resTimestampMock: 2024-10-19T19:04:24.292168839Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-3 +spec: + metadata: + operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "PyMongo|c|MongoEngine","version": "4.10.1|0.29.1"},"os": {"type": "Linux","name": "Linux","architecture": "x86_64","version": "6.5.0-1025-azure"},"platform": "CPython 3.12.1.final.0","env": {"container": {"runtime": "docker"}}},"compression": [],"saslSupportedMechs": "admin.admin","speculativeAuthenticate": {"saslStart": {"$numberInt":"1"},"mechanism": "SCRAM-SHA-256","payload": {"$binary":{"base64":"biwsbj1hZG1pbixyPUlTVGRlTDJER25EeUd0MTMyM3dlbWo0d3BOTWZJRmhpalB6bThiUTk3ck09","subType":"00"}},"autoAuthorize": {"$numberInt":"1"},"options": {"skipEmptyExchange": true},"db": "admin"}}, returnFieldsSelector: }' + type: config + requests: + - header: + length: 598 + requestId: 1957747793 + responseTo: 0 + Opcode: 2004 + message: + flags: 0 + collection_name: admin.$cmd + number_to_skip: 0 + number_to_return: -1 + query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"PyMongo|c|MongoEngine","version":"4.10.1|0.29.1"},"os":{"type":"Linux","name":"Linux","architecture":"x86_64","version":"6.5.0-1025-azure"},"platform":"CPython 3.12.1.final.0","env":{"container":{"runtime":"docker"}}},"compression":[],"saslSupportedMechs":"admin.admin","speculativeAuthenticate":{"saslStart":{"$numberInt":"1"},"mechanism":"SCRAM-SHA-256","payload":{"$binary":{"base64":"biwsbj1hZG1pbixyPUlTVGRlTDJER25EeUd0MTMyM3dlbWo0d3BOTWZJRmhpalB6bThiUTk3ck09","subType":"00"}},"autoAuthorize":{"$numberInt":"1"},"options":{"skipEmptyExchange":true},"db":"admin"}}' + return_fields_selector: "" + responses: + - header: + length: 594 + requestId: 133 + responseTo: 1957747793 + Opcode: 1 + message: + response_flags: 8 + cursor_id: 0 + starting_from: 0 + number_returned: 1 + documents: + - '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"6713fe1e569046d9af25b0b5"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1729364666167"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"24"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"25"},"readOnly":false,"saslSupportedMechs":["SCRAM-SHA-256","SCRAM-SHA-1"],"speculativeAuthenticate":{"conversationId":{"$numberInt":"1"},"done":false,"payload":{"$binary":{"base64":"cj1JU1RkZUwyREduRHlHdDEzMjN3ZW1qNHdwTk1mSUZoaWpQem04YlE5N3JNPS9lU1YzSWZBb3ZIemlUWXFJVHAwbWx5ZjgySzdydlZFLHM9OUtUMFQ5b0YrUlQzV0dFWmZTb3gzNXNZYng2d2RlZVNEeXpHWWc9PSxpPTE1MDAw","subType":"00"}}},"ok":{"$numberDouble":"1.0"}}' + read_delay: 802600 + created: 1729364666 + reqTimestampMock: 2024-10-19T19:04:26.166927988Z + resTimestampMock: 2024-10-19T19:04:26.167862404Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-4 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"saslContinue":{"$numberInt":"1"},"conversationId":{"$numberInt":"1"},"payload":{"$binary":{"base64":"Yz1iaXdzLHI9SVNUZGVMMkRHbkR5R3QxMzIzd2VtajR3cE5NZklGaGlqUHptOGJROTdyTT0vZVNWM0lmQW92SHppVFlxSVRwMG1seWY4Mks3cnZWRSxwPXlERG1PYzA1ZWdwaEpaallKZTY2MnEyWGs3SHNKS1VDaU1vVVV6SW5VTVk9","subType":"00"}},"$db":"admin"} }], checksum: 0 }' + type: config + requests: + - header: + length: 225 + requestId: 424238335 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"saslContinue":{"$numberInt":"1"},"conversationId":{"$numberInt":"1"},"payload":{"$binary":{"base64":"Yz1iaXdzLHI9SVNUZGVMMkRHbkR5R3QxMzIzd2VtajR3cE5NZklGaGlqUHptOGJROTdyTT0vZVNWM0lmQW92SHppVFlxSVRwMG1seWY4Mks3cnZWRSxwPXlERG1PYzA1ZWdwaEpaallKZTY2MnEyWGs3SHNKS1VDaU1vVVV6SW5VTVk9","subType":"00"}},"$db":"admin"} }' + checksum: 0 + read_delay: 5086782 + responses: + - header: + length: 125 + requestId: 134 + responseTo: 424238335 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"conversationId":{"$numberInt":"1"},"done":true,"payload":{"$binary":{"base64":"dj1VUzhRbi8wbTErM1JoS2tNNmZRaHFqK2lRdGxIaUtXendmL3VKZXgwSVZRPQ==","subType":"00"}},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 304558 + created: 1729364666 + reqTimestampMock: 2024-10-19T19:04:26.173006844Z + resTimestampMock: 2024-10-19T19:04:26.173411679Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-5 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"item","filter":{},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }], checksum: 0 }' + requests: + - header: + length: 112 + requestId: 719885386 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"item","filter":{},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + checksum: 0 + read_delay: 572687 + responses: + - header: + length: 224 + requestId: 135 + responseTo: 719885386 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"6713ff286b75650a56907678"},"name":"Gadget C","quantity":{"$numberInt":"200"},"description":"A versatile gadget with numerous features."}],"id":{"$numberLong":"0"},"ns":"inventory_db.item"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 492359 + created: 1729364666 + reqTimestampMock: 2024-10-19T19:04:26.174063774Z + resTimestampMock: 2024-10-19T19:04:26.174647202Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-6 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }], checksum: 0 }' + type: config + requests: + - header: + length: 65 + requestId: 1957747793 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }' + checksum: 0 + read_delay: 10001778949 + responses: + - header: + length: 314 + requestId: 136 + responseTo: 1957747793 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"6713fe1e569046d9af25b0b5"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1729364674294"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"21"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"25"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 370160 + created: 1729364674 + reqTimestampMock: 2024-10-19T19:04:34.294047203Z + resTimestampMock: 2024-10-19T19:04:34.294532769Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-7 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"insert":"item","ordered":true,"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }, { SectionSingle identifier: documents , msgs: [ {"_id":{"$oid":"671402e72887cb944c43b8ba"},"name":"Gadget C","quantity":{"$numberInt":"200"},"description":"A versatile gadget with numerous features."} ] }], checksum: 0 }' + requests: + - header: + length: 241 + requestId: 1350490027 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"insert":"item","ordered":true,"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + - '{ SectionSingle identifier: documents , msgs: [ {"_id":{"$oid":"671402e72887cb944c43b8ba"},"name":"Gadget C","quantity":{"$numberInt":"200"},"description":"A versatile gadget with numerous features."} ] }' + checksum: 0 + read_delay: 45695442201 + responses: + - header: + length: 45 + requestId: 157 + responseTo: 1350490027 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 498127 + created: 1729364711 + reqTimestampMock: 2024-10-19T19:05:11.870212614Z + resTimestampMock: 2024-10-19T19:05:11.870816598Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-8 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"item","filter":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"2"},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }], checksum: 0 }' + requests: + - header: + length: 140 + requestId: 1365180540 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"item","filter":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"2"},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + checksum: 0 + read_delay: 39270780350 + responses: + - header: + length: 224 + requestId: 174 + responseTo: 1365180540 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"6713ff286b75650a56907678"},"name":"Gadget C","quantity":{"$numberInt":"200"},"description":"A versatile gadget with numerous features."}],"id":{"$numberLong":"0"},"ns":"inventory_db.item"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 407362 + created: 1729364751 + reqTimestampMock: 2024-10-19T19:05:51.141679843Z + resTimestampMock: 2024-10-19T19:05:51.142418243Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-9 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"item","filter":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"2"},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }], checksum: 0 }' + requests: + - header: + length: 140 + requestId: 233665123 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"item","filter":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"2"},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + checksum: 0 + read_delay: 99571750729 + responses: + - header: + length: 224 + requestId: 215 + responseTo: 233665123 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"6713ff286b75650a56907678"},"name":"Gadget C","quantity":{"$numberInt":"200"},"description":"A versatile gadget with numerous features."}],"id":{"$numberLong":"0"},"ns":"inventory_db.item"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 421459 + created: 1729364850 + reqTimestampMock: 2024-10-19T19:07:30.714254912Z + resTimestampMock: 2024-10-19T19:07:30.714797717Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-10 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"update":"item","ordered":true,"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }, { SectionSingle identifier: updates , msgs: [ {"q":{"_id":{"$oid":"6713ff286b75650a56907678"}},"u":{"$set":{"name":"Updated Widget A","quantity":{"$numberInt":"120"},"description":"An updated description for Widget A."}},"multi":false,"upsert":true} ] }], checksum: 0 }' + requests: + - header: + length: 285 + requestId: 2145174067 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"update":"item","ordered":true,"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + - '{ SectionSingle identifier: updates , msgs: [ {"q":{"_id":{"$oid":"6713ff286b75650a56907678"}},"u":{"$set":{"name":"Updated Widget A","quantity":{"$numberInt":"120"},"description":"An updated description for Widget A."}},"multi":false,"upsert":true} ] }' + checksum: 0 + read_delay: 1179499 + responses: + - header: + length: 60 + requestId: 216 + responseTo: 2145174067 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"nModified":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 511395 + created: 1729364850 + reqTimestampMock: 2024-10-19T19:07:30.716062926Z + resTimestampMock: 2024-10-19T19:07:30.716661092Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-11 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"item","filter":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"2"},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }], checksum: 0 }' + requests: + - header: + length: 140 + requestId: 1369133069 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"item","filter":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"2"},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + checksum: 0 + read_delay: 49267790804 + responses: + - header: + length: 226 + requestId: 237 + responseTo: 1369133069 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"6713ff286b75650a56907678"},"name":"Updated Widget A","quantity":{"$numberInt":"120"},"description":"An updated description for Widget A."}],"id":{"$numberLong":"0"},"ns":"inventory_db.item"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 458793 + created: 1729364899 + reqTimestampMock: 2024-10-19T19:08:19.984540733Z + resTimestampMock: 2024-10-19T19:08:19.98511404Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-12 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"delete":"item","ordered":true,"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }, { SectionSingle identifier: deletes , msgs: [ {"q":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"0"}} ] }], checksum: 0 }' + requests: + - header: + length: 165 + requestId: 1125898167 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"delete":"item","ordered":true,"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + - '{ SectionSingle identifier: deletes , msgs: [ {"q":{"_id":{"$oid":"6713ff286b75650a56907678"}},"limit":{"$numberInt":"0"}} ] }' + checksum: 0 + read_delay: 750270 + responses: + - header: + length: 45 + requestId: 238 + responseTo: 1125898167 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 377687 + created: 1729364899 + reqTimestampMock: 2024-10-19T19:08:19.985934962Z + resTimestampMock: 2024-10-19T19:08:19.986405462Z +--- +version: api.keploy.io/v1beta1 +kind: Mongo +name: mock-13 +spec: + metadata: + operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"item","filter":{},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }], checksum: 0 }' + requests: + - header: + length: 112 + requestId: 2089018456 + responseTo: 0 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"find":"item","filter":{},"lsid":{"id":{"$binary":{"base64":"czkuEpfTSBak1dx74/p4iA==","subType":"04"}}},"$db":"inventory_db"} }' + checksum: 0 + read_delay: 8085196300 + responses: + - header: + length: 224 + requestId: 243 + responseTo: 2089018456 + Opcode: 2013 + message: + flagBits: 0 + sections: + - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"671402e72887cb944c43b8ba"},"name":"Gadget C","quantity":{"$numberInt":"200"},"description":"A versatile gadget with numerous features."}],"id":{"$numberLong":"0"},"ns":"inventory_db.item"},"ok":{"$numberDouble":"1.0"}} }' + checksum: 0 + read_delay: 486370 + created: 1729364908 + reqTimestampMock: 2024-10-19T19:08:28.071683686Z + resTimestampMock: 2024-10-19T19:08:28.072290581Z diff --git a/django-mongo/django_mongo/keploy/test-set-0/tests/test-1.yaml b/django-mongo/django_mongo/keploy/test-set-0/tests/test-1.yaml new file mode 100755 index 0000000..47b6d72 --- /dev/null +++ b/django-mongo/django_mongo/keploy/test-set-0/tests/test-1.yaml @@ -0,0 +1,44 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-1 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/api/items/ + header: + Accept: '*/*' + Host: localhost:8000 + User-Agent: curl/7.68.0 + body: "" + timestamp: 2024-10-19T19:04:26.158535156Z + resp: + status_code: 200 + header: + Allow: GET, POST, HEAD, OPTIONS + Content-Length: "127" + Content-Type: application/json + Date: Sat, 19 Oct 2024 19:04:26 GMT + Referrer-Policy: same-origin + Server: WSGIServer/0.2 CPython/3.12.1 + Vary: Accept, Cookie + X-Content-Type-Options: nosniff + X-Frame-Options: DENY + body: '[{"id":"6713ff286b75650a56907678","name":"Gadget C","quantity":200,"description":"A versatile gadget with numerous features."}]' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-19T19:04:28.257078042Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1729364668 +curl: | + curl --request GET \ + --url http://localhost:8000/api/items/ \ + --header 'Accept: */*' \ + --header 'Host: localhost:8000' \ + --header 'User-Agent: curl/7.68.0' \ diff --git a/django-mongo/django_mongo/keploy/test-set-0/tests/test-2.yaml b/django-mongo/django_mongo/keploy/test-set-0/tests/test-2.yaml new file mode 100755 index 0000000..3c83896 --- /dev/null +++ b/django-mongo/django_mongo/keploy/test-set-0/tests/test-2.yaml @@ -0,0 +1,53 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-2 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/api/items/ + header: + Accept: '*/*' + Content-Length: "113" + Content-Type: application/json + Host: localhost:8000 + User-Agent: curl/7.68.0 + body: |- + { + "name": "Gadget C", + "quantity": 200, + "description": "A versatile gadget with numerous features." + } + timestamp: 2024-10-19T19:05:11.862316346Z + resp: + status_code: 201 + header: + Allow: GET, POST, HEAD, OPTIONS + Content-Length: "93" + Content-Type: application/json + Date: Sat, 19 Oct 2024 19:05:11 GMT + Referrer-Policy: same-origin + Server: WSGIServer/0.2 CPython/3.12.1 + Vary: Accept, Cookie + X-Content-Type-Options: nosniff + X-Frame-Options: DENY + body: '{"name":"Gadget C","quantity":200,"description":"A versatile gadget with numerous features."}' + status_message: Created + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-19T19:05:13.966578004Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1729364713 +curl: |- + curl --request POST \ + --url http://localhost:8000/api/items/ \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:8000' \ + --header 'User-Agent: curl/7.68.0' \ + --header 'Accept: */*' \ + --data "{\n \"name\": \"Gadget C\",\n \"quantity\": 200,\n \"description\": \"A versatile gadget with numerous features.\"\n }" diff --git a/django-mongo/django_mongo/keploy/test-set-0/tests/test-3.yaml b/django-mongo/django_mongo/keploy/test-set-0/tests/test-3.yaml new file mode 100755 index 0000000..f9ef6f5 --- /dev/null +++ b/django-mongo/django_mongo/keploy/test-set-0/tests/test-3.yaml @@ -0,0 +1,44 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-3 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/api/items/6713ff286b75650a56907678/ + header: + Accept: '*/*' + Host: localhost:8000 + User-Agent: curl/7.68.0 + body: "" + timestamp: 2024-10-19T19:05:51.140167751Z + resp: + status_code: 200 + header: + Allow: GET, PUT, DELETE, HEAD, OPTIONS + Content-Length: "125" + Content-Type: application/json + Date: Sat, 19 Oct 2024 19:05:51 GMT + Referrer-Policy: same-origin + Server: WSGIServer/0.2 CPython/3.12.1 + Vary: Accept, Cookie + X-Content-Type-Options: nosniff + X-Frame-Options: DENY + body: '{"id":"6713ff286b75650a56907678","name":"Gadget C","quantity":200,"description":"A versatile gadget with numerous features."}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-19T19:05:53.163490949Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1729364753 +curl: | + curl --request GET \ + --url http://localhost:8000/api/items/6713ff286b75650a56907678/ \ + --header 'User-Agent: curl/7.68.0' \ + --header 'Accept: */*' \ + --header 'Host: localhost:8000' \ diff --git a/django-mongo/django_mongo/keploy/test-set-0/tests/test-4.yaml b/django-mongo/django_mongo/keploy/test-set-0/tests/test-4.yaml new file mode 100755 index 0000000..5b841a2 --- /dev/null +++ b/django-mongo/django_mongo/keploy/test-set-0/tests/test-4.yaml @@ -0,0 +1,48 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-4 +spec: + metadata: {} + req: + method: PUT + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/api/items/6713ff286b75650a56907678/ + header: + Accept: '*/*' + Content-Length: "110" + Content-Type: application/json + Host: localhost:8000 + User-Agent: curl/7.68.0 + body: '{ "name": "Updated Widget A", "quantity": 120, "description": "An updated description for Widget A."}' + timestamp: 2024-10-19T19:07:30.712800581Z + resp: + status_code: 200 + header: + Allow: GET, PUT, DELETE, HEAD, OPTIONS + Content-Length: "127" + Content-Type: application/json + Date: Sat, 19 Oct 2024 19:07:30 GMT + Referrer-Policy: same-origin + Server: WSGIServer/0.2 CPython/3.12.1 + Vary: Accept, Cookie + X-Content-Type-Options: nosniff + X-Frame-Options: DENY + body: '{"id":"6713ff286b75650a56907678","name":"Updated Widget A","quantity":120,"description":"An updated description for Widget A."}' + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-19T19:07:32.720391721Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1729364852 +curl: |- + curl --request PUT \ + --url http://localhost:8000/api/items/6713ff286b75650a56907678/ \ + --header 'Accept: */*' \ + --header 'Content-Type: application/json' \ + --header 'Host: localhost:8000' \ + --header 'User-Agent: curl/7.68.0' \ + --data "{ \"name\": \"Updated Widget A\", \"quantity\": 120, \"description\": \"An updated description for Widget A.\"}" diff --git a/django-mongo/django_mongo/keploy/test-set-0/tests/test-5.yaml b/django-mongo/django_mongo/keploy/test-set-0/tests/test-5.yaml new file mode 100755 index 0000000..8bd7999 --- /dev/null +++ b/django-mongo/django_mongo/keploy/test-set-0/tests/test-5.yaml @@ -0,0 +1,43 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-5 +spec: + metadata: {} + req: + method: DELETE + proto_major: 1 + proto_minor: 1 + url: http://localhost:8000/api/items/6713ff286b75650a56907678/ + header: + Accept: '*/*' + Host: localhost:8000 + User-Agent: curl/7.68.0 + body: "" + timestamp: 2024-10-19T19:08:19.983000488Z + resp: + status_code: 204 + header: + Allow: GET, PUT, DELETE, HEAD, OPTIONS + Content-Length: "0" + Date: Sat, 19 Oct 2024 19:08:19 GMT + Referrer-Policy: same-origin + Server: WSGIServer/0.2 CPython/3.12.1 + Vary: Accept, Cookie + X-Content-Type-Options: nosniff + X-Frame-Options: DENY + body: "" + status_message: No Content + proto_major: 0 + proto_minor: 0 + timestamp: 2024-10-19T19:08:22.044354383Z + objects: [] + assertions: + noise: + header.Date: [] + created: 1729364902 +curl: | + curl --request DELETE \ + --url http://localhost:8000/api/items/6713ff286b75650a56907678/ \ + --header 'User-Agent: curl/7.68.0' \ + --header 'Accept: */*' \ + --header 'Host: localhost:8000' \ diff --git a/django-mongo/django_mongo/manage.py b/django-mongo/django_mongo/manage.py new file mode 100755 index 0000000..f3fd315 --- /dev/null +++ b/django-mongo/django_mongo/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_mongo.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/django-mongo/django_mongo/products.json b/django-mongo/django_mongo/products.json new file mode 100644 index 0000000..1099bda --- /dev/null +++ b/django-mongo/django_mongo/products.json @@ -0,0 +1,32 @@ +[ + { + "name": "Widget A", + "quantity": 100, + "description": "A high-quality widget that serves many purposes." + }, + { + "name": "Widget B", + "quantity": 150, + "description": "An essential widget for every toolkit." + }, + { + "name": "Gadget C", + "quantity": 200, + "description": "A versatile gadget with numerous features." + }, + { + "name": "Gadget D", + "quantity": 50, + "description": "A compact gadget perfect for small spaces." + }, + { + "name": "Tool E", + "quantity": 75, + "description": "A durable tool designed for heavy use." + }, + { + "name": "Tool F", + "quantity": 120, + "description": "An ergonomic tool for comfortable handling." + } +] \ No newline at end of file diff --git a/django-mongo/django_mongo/requirements.txt b/django-mongo/django_mongo/requirements.txt new file mode 100644 index 0000000..cc08838 --- /dev/null +++ b/django-mongo/django_mongo/requirements.txt @@ -0,0 +1,3 @@ +Django>=3.2,<4.0 +djangorestframework>=3.12,<4.0 +mongoengine>=0.20,<1.0 \ No newline at end of file