Skip to content

drevesina51/cbr_mock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CBR Mock API Service

FastAPI mock service for Central Bank of Russia currency rates API

Features

  • Full mock implementation of CBR API endpoint
  • Dynamic response generation based on request parameters
  • Built-in request logging to SQLite database
  • Automatic Swagger documentation
  • Load testing support

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/cbr_mock.git
    cd cbr_mock
  2. Create and activate virtual environment:

    • Linux/Mac:
      python -m venv venv
      source venv/bin/activate
    • Windows:
      python -m venv venv
      .\venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt

Usage

Running the server

  • Development mode with auto-reload:
    make run
  • Production mode:
    make prod

Endpoints

  • Main endpoint: GET /scripts/XML_daily.asp?date_req=DD/MM/YYYY
  • Healthcheck: GET /healthcheck
  • Request log: GET /requests-log
  • Reset test state: POST /reset-test-state

Examples

  • Successful request:
    curl "http://localhost:8000/scripts/XML_daily.asp?date_req=22/07/2025"
  • Force error response:
    curl "http://localhost:8000/scripts/XML_daily.asp?date_req=22/07/2025&force_error=true"

Testing

  • Run basic tests:
    make test
  • Run load testing (requires locust):
    make load-test

Implementation Status

✅ Fully Implemented

  • Microservice architecture (FastAPI)
  • Asynchronous interaction
  • Unique data generation per test
  • No hardcoded responses
  • No headers usage
  • Makefile with commands
  • Swagger documentation
  • Database integration (SQLite)

⚠️ Not Implemented

  • Proto files (gRPC interface)
  • Golang version

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors