Skip to content

Commit

Permalink
fix test error
Browse files Browse the repository at this point in the history
  • Loading branch information
yibeichan committed Feb 25, 2025
1 parent 238e75f commit 85b9ff3
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ jobs:
- name: Build and test
run: |
docker compose version
# Ensure tests directory exists and is copied to the right place
mkdir -p docker/backend/tests
cp tests/test_api.py docker/backend/tests/
docker compose -f docker-compose.dev.yml build
docker compose -f docker-compose.dev.yml up -d
docker compose -f docker-compose.dev.yml exec -T reproschema-server pip install pytest pytest-asyncio pytest-cov
docker compose -f docker-compose.dev.yml exec -T reproschema-server python -m pytest tests/
docker compose -f docker-compose.dev.yml exec -T reproschema-server python -m pytest /app/tests/
docker compose -f docker-compose.dev.yml down
env:
# Core settings
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.8'
services:
reproschema-server:
container_name: ${CONTAINER_NAME:-reproschema-server}
Expand All @@ -19,7 +18,7 @@ services:
- ${DATA_PATH:-./data}:/data:rw
# Development volumes
- ./docker/backend:/app # For live backend changes
- ./tests:/app/tests:ro # Mount from project root, read-only
- ./docker/backend/tests:/app/tests:ro # Mount from backend directory
environment:
# Core settings
- NODE_ENV=${NODE_ENV:-development} # Default to development
Expand Down
59 changes: 59 additions & 0 deletions docs/api-testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# API Testing Guide

## Overview
This guide explains how to test the ReproSchema backend API endpoints manually.

## Prerequisites
- `curl` command-line tool
- Running ReproSchema server (via `docker compose up`)
- Initial token (found in backend logs)

## Getting Started

1. First, check the backend logs to get the initial token:


2. Get an auth token using the initial token:



3. Use the auth token to submit data:


## API Endpoints

### Health Check


### Get Auth Token

Parameters:
- `token`: Initial token from backend logs
- `project`: Project name (default: "study")
- `expiry_minutes`: Token expiry in minutes (default: 90)

### Submit Data

Headers:
- `Authorization`: Auth token from `/api/token` endpoint
- `Content-Type`: Must be `application/json`

### Get Schema


## Data Storage
Submitted responses are stored in:


## Common Issues
1. "Invalid token" error:
- Make sure you're using the correct initial token from logs
- Initial tokens are regenerated on container restart

2. "Invalid auth token" error:
- Auth tokens expire after 90 minutes
- Get a new auth token using the initial token
- Don't include "Bearer " prefix in Authorization header

## Development Testing
For development mode features:

0 comments on commit 85b9ff3

Please sign in to comment.