fix: restore original simple_refrig_api and platform path fixes
This commit is contained in:
44
tests/test_diagram_api.py
Normal file
44
tests/test_diagram_api.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import base64
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_diagram_json_no_image():
|
||||
body = {
|
||||
'refrigerant': 'R290',
|
||||
'pressure_range': {'min': 0.1, 'max': 10.0},
|
||||
'format': 'json',
|
||||
'include_isotherms': True,
|
||||
'width': 800,
|
||||
'height': 600,
|
||||
'dpi': 100
|
||||
}
|
||||
r = client.post('/api/v1/diagrams/ph', json=body)
|
||||
assert r.status_code == 200
|
||||
j = r.json()
|
||||
# image key should not be present for json-only
|
||||
assert 'image' not in j
|
||||
assert 'data' in j
|
||||
|
||||
|
||||
def test_diagram_png_includes_image():
|
||||
body = {
|
||||
'refrigerant': 'R290',
|
||||
'pressure_range': {'min': 0.1, 'max': 10.0},
|
||||
'format': 'png',
|
||||
'include_isotherms': True,
|
||||
'width': 800,
|
||||
'height': 600,
|
||||
'dpi': 100
|
||||
}
|
||||
r = client.post('/api/v1/diagrams/ph', json=body)
|
||||
assert r.status_code == 200
|
||||
j = r.json()
|
||||
assert 'image' in j
|
||||
# Validate base64 decodes
|
||||
decoded = base64.b64decode(j['image'])
|
||||
assert len(decoded) > 10
|
||||
19
tests/test_economizer_unit.py
Normal file
19
tests/test_economizer_unit.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import sys, os
|
||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
||||
if ROOT not in sys.path:
|
||||
sys.path.insert(0, ROOT)
|
||||
|
||||
from app.core.refrigerant_loader import RefrigerantLibrary
|
||||
from app.services.cycle_calculator import CycleCalculator
|
||||
|
||||
|
||||
def test_economizer_runs():
|
||||
refrigerant = RefrigerantLibrary('R290')
|
||||
calc = CycleCalculator(refrigerant)
|
||||
evap = 0.2 * 1e5
|
||||
cond = 6.0 * 1e5
|
||||
inter = 2.0 * 1e5
|
||||
res = calc.calculate_cycle_with_economizer(evap, cond, inter, mass_flow=0.1)
|
||||
assert 'performance' in res
|
||||
assert 'flash_fraction' in res['performance']
|
||||
assert 0.0 <= res['performance']['flash_fraction'] <= 1.0
|
||||
Reference in New Issue
Block a user