Files

74 lines
2.8 KiB
Python

import pytest
@pytest.fixture
def sample_har_data():
return {
"log": {
"version": "1.2",
"creator": {"name": "Test", "version": "1.0"},
"entries": [
{
"startedDateTime": "2024-01-01T00:00:00.000Z",
"time": 100,
"request": {
"method": "GET",
"url": "https://api.example.com/users/123",
"headers": [
{"name": "Content-Type", "value": "application/json"},
{"name": "Authorization", "value": "Bearer test_token"},
],
"queryString": [{"name": "include", "value": "profile"}],
"postData": None,
},
"response": {
"status": 200,
"statusText": "OK",
"headers": [
{"name": "Content-Type", "value": "application/json"},
],
"content": {
"mimeType": "application/json",
"text": '{"id": 123, "name": "John Doe", "email": "john@example.com"}',
},
},
},
{
"startedDateTime": "2024-01-01T00:00:01.000Z",
"time": 200,
"request": {
"method": "POST",
"url": "https://api.example.com/users",
"headers": [
{"name": "Content-Type", "value": "application/json"},
],
"queryString": [],
"postData": {
"mimeType": "application/json",
"text": '{"name": "Jane Doe", "email": "jane@example.com"}',
},
},
"response": {
"status": 201,
"statusText": "Created",
"headers": [
{"name": "Content-Type", "value": "application/json"},
],
"content": {
"mimeType": "application/json",
"text": '{"id": 456, "name": "Jane Doe", "email": "jane@example.com", "created_at": "2024-01-01T00:00:01Z"}',
},
},
},
],
}
}
@pytest.fixture
def sample_har_file(tmp_path, sample_har_data):
import json
har_file = tmp_path / "test.har"
har_file.write_text(json.dumps(sample_har_data))
return str(har_file)