Add sys import to test files and remove obsolete integration tests
Some checks failed
API Endpoint Tests / test-api-endpoints (push) Successful in 9s
Blockchain Synchronization Verification / sync-verification (push) Failing after 1s
CLI Tests / test-cli (push) Failing after 3s
Documentation Validation / validate-docs (push) Successful in 6s
Documentation Validation / validate-policies-strict (push) Successful in 2s
Integration Tests / test-service-integration (push) Successful in 40s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 1s
P2P Network Verification / p2p-verification (push) Successful in 2s
Production Tests / Production Integration Tests (push) Successful in 21s
Python Tests / test-python (push) Successful in 13s
Security Scanning / security-scan (push) Failing after 46s
Smart Contract Tests / test-solidity (map[name:aitbc-token path:packages/solidity/aitbc-token]) (push) Successful in 17s
Smart Contract Tests / lint-solidity (push) Successful in 10s
Some checks failed
API Endpoint Tests / test-api-endpoints (push) Successful in 9s
Blockchain Synchronization Verification / sync-verification (push) Failing after 1s
CLI Tests / test-cli (push) Failing after 3s
Documentation Validation / validate-docs (push) Successful in 6s
Documentation Validation / validate-policies-strict (push) Successful in 2s
Integration Tests / test-service-integration (push) Successful in 40s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 1s
P2P Network Verification / p2p-verification (push) Successful in 2s
Production Tests / Production Integration Tests (push) Successful in 21s
Python Tests / test-python (push) Successful in 13s
Security Scanning / security-scan (push) Failing after 46s
Smart Contract Tests / test-solidity (map[name:aitbc-token path:packages/solidity/aitbc-token]) (push) Successful in 17s
Smart Contract Tests / lint-solidity (push) Successful in 10s
- Add sys import to 29 test files across agent-coordinator, blockchain-event-bridge, blockchain-node, and coordinator-api - Remove apps/blockchain-event-bridge/tests/test_integration.py (obsolete bridge integration tests) - Remove apps/coordinator-api/tests/test_integration.py (obsolete API integration tests) - Implement GPU registration in marketplace_gpu.py with GPURegistry model persistence
This commit is contained in:
1
apps/compliance-service/tests/__init__.py
Normal file
1
apps/compliance-service/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Compliance service tests"""
|
||||
@@ -0,0 +1,193 @@
|
||||
"""Edge case and error handling tests for compliance service"""
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock, patch
|
||||
from fastapi.testclient import TestClient
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
from main import app, KYCRequest, ComplianceReport, TransactionMonitoring, kyc_records, compliance_reports, suspicious_transactions, compliance_rules
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def reset_state():
|
||||
"""Reset global state before each test"""
|
||||
kyc_records.clear()
|
||||
compliance_reports.clear()
|
||||
suspicious_transactions.clear()
|
||||
compliance_rules.clear()
|
||||
yield
|
||||
kyc_records.clear()
|
||||
compliance_reports.clear()
|
||||
suspicious_transactions.clear()
|
||||
compliance_rules.clear()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_kyc_request_empty_fields():
|
||||
"""Test KYCRequest with empty fields"""
|
||||
kyc = KYCRequest(
|
||||
user_id="",
|
||||
name="",
|
||||
email="",
|
||||
document_type="",
|
||||
document_number="",
|
||||
address={}
|
||||
)
|
||||
assert kyc.user_id == ""
|
||||
assert kyc.name == ""
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_compliance_report_invalid_severity():
|
||||
"""Test ComplianceReport with invalid severity"""
|
||||
report = ComplianceReport(
|
||||
report_type="test",
|
||||
description="test",
|
||||
severity="invalid", # Not in low/medium/high/critical
|
||||
details={}
|
||||
)
|
||||
assert report.severity == "invalid"
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_transaction_monitoring_zero_amount():
|
||||
"""Test TransactionMonitoring with zero amount"""
|
||||
tx = TransactionMonitoring(
|
||||
transaction_id="tx123",
|
||||
user_id="user123",
|
||||
amount=0.0,
|
||||
currency="BTC",
|
||||
counterparty="counterparty1",
|
||||
timestamp=datetime.utcnow()
|
||||
)
|
||||
assert tx.amount == 0.0
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_transaction_monitoring_negative_amount():
|
||||
"""Test TransactionMonitoring with negative amount"""
|
||||
tx = TransactionMonitoring(
|
||||
transaction_id="tx123",
|
||||
user_id="user123",
|
||||
amount=-1000.0,
|
||||
currency="BTC",
|
||||
counterparty="counterparty1",
|
||||
timestamp=datetime.utcnow()
|
||||
)
|
||||
assert tx.amount == -1000.0
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_kyc_with_missing_address_fields():
|
||||
"""Test KYC submission with missing address fields"""
|
||||
client = TestClient(app)
|
||||
kyc = KYCRequest(
|
||||
user_id="user123",
|
||||
name="John Doe",
|
||||
email="john@example.com",
|
||||
document_type="passport",
|
||||
document_number="ABC123",
|
||||
address={"city": "New York"} # Missing other fields
|
||||
)
|
||||
response = client.post("/api/v1/kyc/submit", json=kyc.model_dump())
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_compliance_report_empty_details():
|
||||
"""Test compliance report with empty details"""
|
||||
client = TestClient(app)
|
||||
report = ComplianceReport(
|
||||
report_type="test",
|
||||
description="test",
|
||||
severity="low",
|
||||
details={}
|
||||
)
|
||||
response = client.post("/api/v1/compliance/report", json=report.model_dump())
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_compliance_rule_missing_fields():
|
||||
"""Test compliance rule with missing fields"""
|
||||
client = TestClient(app)
|
||||
rule_data = {
|
||||
"name": "Test Rule"
|
||||
# Missing description, type, etc.
|
||||
}
|
||||
response = client.post("/api/v1/rules/create", json=rule_data)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["name"] == "Test Rule"
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_dashboard_with_no_data():
|
||||
"""Test dashboard with no data"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/dashboard")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["summary"]["total_users"] == 0
|
||||
assert data["summary"]["total_reports"] == 0
|
||||
assert data["summary"]["total_transactions"] == 0
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_monitor_transaction_with_future_timestamp():
|
||||
"""Test monitoring transaction with future timestamp"""
|
||||
client = TestClient(app)
|
||||
tx = TransactionMonitoring(
|
||||
transaction_id="tx123",
|
||||
user_id="user123",
|
||||
amount=1000.0,
|
||||
currency="BTC",
|
||||
counterparty="counterparty1",
|
||||
timestamp=datetime(2030, 1, 1) # Future timestamp
|
||||
)
|
||||
response = client.post("/api/v1/monitoring/transaction", json=tx.model_dump(mode='json'))
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_monitor_transaction_with_past_timestamp():
|
||||
"""Test monitoring transaction with past timestamp"""
|
||||
client = TestClient(app)
|
||||
tx = TransactionMonitoring(
|
||||
transaction_id="tx123",
|
||||
user_id="user123",
|
||||
amount=1000.0,
|
||||
currency="BTC",
|
||||
counterparty="counterparty1",
|
||||
timestamp=datetime(2020, 1, 1) # Past timestamp
|
||||
)
|
||||
response = client.post("/api/v1/monitoring/transaction", json=tx.model_dump(mode='json'))
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_kyc_list_with_multiple_records():
|
||||
"""Test listing KYC with multiple records"""
|
||||
client = TestClient(app)
|
||||
|
||||
# Create multiple KYC records
|
||||
for i in range(5):
|
||||
kyc = KYCRequest(
|
||||
user_id=f"user{i}",
|
||||
name=f"User {i}",
|
||||
email=f"user{i}@example.com",
|
||||
document_type="passport",
|
||||
document_number=f"ABC{i}",
|
||||
address={"city": "New York"}
|
||||
)
|
||||
client.post("/api/v1/kyc/submit", json=kyc.model_dump())
|
||||
|
||||
response = client.get("/api/v1/kyc")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["total_records"] == 5
|
||||
assert data["approved"] == 5
|
||||
@@ -0,0 +1,252 @@
|
||||
"""Integration tests for compliance service"""
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock, patch
|
||||
from fastapi.testclient import TestClient
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
from main import app, KYCRequest, ComplianceReport, TransactionMonitoring, kyc_records, compliance_reports, suspicious_transactions, compliance_rules
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def reset_state():
|
||||
"""Reset global state before each test"""
|
||||
kyc_records.clear()
|
||||
compliance_reports.clear()
|
||||
suspicious_transactions.clear()
|
||||
compliance_rules.clear()
|
||||
yield
|
||||
kyc_records.clear()
|
||||
compliance_reports.clear()
|
||||
suspicious_transactions.clear()
|
||||
compliance_rules.clear()
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_root_endpoint():
|
||||
"""Test root endpoint"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["service"] == "AITBC Compliance Service"
|
||||
assert data["status"] == "running"
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_health_check_endpoint():
|
||||
"""Test health check endpoint"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/health")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["status"] == "healthy"
|
||||
assert "kyc_records" in data
|
||||
assert "compliance_reports" in data
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_submit_kyc():
|
||||
"""Test KYC submission"""
|
||||
client = TestClient(app)
|
||||
kyc = KYCRequest(
|
||||
user_id="user123",
|
||||
name="John Doe",
|
||||
email="john@example.com",
|
||||
document_type="passport",
|
||||
document_number="ABC123",
|
||||
address={"street": "123 Main St", "city": "New York", "country": "USA"}
|
||||
)
|
||||
response = client.post("/api/v1/kyc/submit", json=kyc.model_dump())
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["user_id"] == "user123"
|
||||
assert data["status"] == "approved"
|
||||
assert data["risk_score"] == "low"
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_submit_duplicate_kyc():
|
||||
"""Test submitting duplicate KYC"""
|
||||
client = TestClient(app)
|
||||
kyc = KYCRequest(
|
||||
user_id="user123",
|
||||
name="John Doe",
|
||||
email="john@example.com",
|
||||
document_type="passport",
|
||||
document_number="ABC123",
|
||||
address={"street": "123 Main St", "city": "New York", "country": "USA"}
|
||||
)
|
||||
|
||||
# First submission
|
||||
client.post("/api/v1/kyc/submit", json=kyc.model_dump())
|
||||
|
||||
# Second submission should fail
|
||||
response = client.post("/api/v1/kyc/submit", json=kyc.model_dump())
|
||||
assert response.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_kyc_status():
|
||||
"""Test getting KYC status"""
|
||||
client = TestClient(app)
|
||||
kyc = KYCRequest(
|
||||
user_id="user123",
|
||||
name="John Doe",
|
||||
email="john@example.com",
|
||||
document_type="passport",
|
||||
document_number="ABC123",
|
||||
address={"street": "123 Main St", "city": "New York", "country": "USA"}
|
||||
)
|
||||
|
||||
# Submit KYC first
|
||||
client.post("/api/v1/kyc/submit", json=kyc.model_dump())
|
||||
|
||||
# Get KYC status
|
||||
response = client.get("/api/v1/kyc/user123")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["user_id"] == "user123"
|
||||
assert data["status"] == "approved"
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_kyc_status_not_found():
|
||||
"""Test getting KYC status for nonexistent user"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/kyc/nonexistent")
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_list_kyc_records():
|
||||
"""Test listing KYC records"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/kyc")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "kyc_records" in data
|
||||
assert "total_records" in data
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_create_compliance_report():
|
||||
"""Test creating compliance report"""
|
||||
client = TestClient(app)
|
||||
report = ComplianceReport(
|
||||
report_type="suspicious_activity",
|
||||
description="Suspicious transaction detected",
|
||||
severity="high",
|
||||
details={"transaction_id": "tx123"}
|
||||
)
|
||||
response = client.post("/api/v1/compliance/report", json=report.model_dump())
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["severity"] == "high"
|
||||
assert data["status"] == "created"
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_list_compliance_reports():
|
||||
"""Test listing compliance reports"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/compliance/reports")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "reports" in data
|
||||
assert "total_reports" in data
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_monitor_transaction():
|
||||
"""Test transaction monitoring"""
|
||||
client = TestClient(app)
|
||||
tx = TransactionMonitoring(
|
||||
transaction_id="tx123",
|
||||
user_id="user123",
|
||||
amount=1000.0,
|
||||
currency="BTC",
|
||||
counterparty="counterparty1",
|
||||
timestamp=datetime.utcnow()
|
||||
)
|
||||
response = client.post("/api/v1/monitoring/transaction", json=tx.model_dump(mode='json'))
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["transaction_id"] == "tx123"
|
||||
assert "risk_score" in data
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_monitor_suspicious_transaction():
|
||||
"""Test monitoring suspicious transaction"""
|
||||
client = TestClient(app)
|
||||
tx = TransactionMonitoring(
|
||||
transaction_id="tx123",
|
||||
user_id="user123",
|
||||
amount=100000.0,
|
||||
currency="BTC",
|
||||
counterparty="high_risk_entity_1",
|
||||
timestamp=datetime.utcnow()
|
||||
)
|
||||
response = client.post("/api/v1/monitoring/transaction", json=tx.model_dump(mode='json'))
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["status"] == "flagged"
|
||||
assert len(data["flags"]) > 0
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_list_monitored_transactions():
|
||||
"""Test listing monitored transactions"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/monitoring/transactions")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "transactions" in data
|
||||
assert "total_transactions" in data
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_create_compliance_rule():
|
||||
"""Test creating compliance rule"""
|
||||
client = TestClient(app)
|
||||
rule_data = {
|
||||
"name": "High Value Transaction Rule",
|
||||
"description": "Flag transactions over $50,000",
|
||||
"type": "transaction_monitoring",
|
||||
"conditions": {"min_amount": 50000},
|
||||
"actions": ["flag", "report"],
|
||||
"severity": "high"
|
||||
}
|
||||
response = client.post("/api/v1/rules/create", json=rule_data)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["name"] == "High Value Transaction Rule"
|
||||
assert data["active"] is True
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_list_compliance_rules():
|
||||
"""Test listing compliance rules"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/rules")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "rules" in data
|
||||
assert "total_rules" in data
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_compliance_dashboard():
|
||||
"""Test compliance dashboard"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/dashboard")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "summary" in data
|
||||
assert "risk_distribution" in data
|
||||
assert "recent_activity" in data
|
||||
161
apps/compliance-service/tests/test_unit_compliance_service.py
Normal file
161
apps/compliance-service/tests/test_unit_compliance_service.py
Normal file
@@ -0,0 +1,161 @@
|
||||
"""Unit tests for compliance service"""
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock, patch
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
from main import app, KYCRequest, ComplianceReport, TransactionMonitoring, calculate_transaction_risk, check_suspicious_patterns
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_app_initialization():
|
||||
"""Test that the FastAPI app initializes correctly"""
|
||||
assert app is not None
|
||||
assert app.title == "AITBC Compliance Service"
|
||||
assert app.version == "1.0.0"
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_kyc_request_model():
|
||||
"""Test KYCRequest model"""
|
||||
kyc = KYCRequest(
|
||||
user_id="user123",
|
||||
name="John Doe",
|
||||
email="john@example.com",
|
||||
document_type="passport",
|
||||
document_number="ABC123",
|
||||
address={"street": "123 Main St", "city": "New York", "country": "USA"}
|
||||
)
|
||||
assert kyc.user_id == "user123"
|
||||
assert kyc.name == "John Doe"
|
||||
assert kyc.email == "john@example.com"
|
||||
assert kyc.document_type == "passport"
|
||||
assert kyc.document_number == "ABC123"
|
||||
assert kyc.address["city"] == "New York"
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_compliance_report_model():
|
||||
"""Test ComplianceReport model"""
|
||||
report = ComplianceReport(
|
||||
report_type="suspicious_activity",
|
||||
description="Suspicious transaction detected",
|
||||
severity="high",
|
||||
details={"transaction_id": "tx123"}
|
||||
)
|
||||
assert report.report_type == "suspicious_activity"
|
||||
assert report.description == "Suspicious transaction detected"
|
||||
assert report.severity == "high"
|
||||
assert report.details["transaction_id"] == "tx123"
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_transaction_monitoring_model():
|
||||
"""Test TransactionMonitoring model"""
|
||||
tx = TransactionMonitoring(
|
||||
transaction_id="tx123",
|
||||
user_id="user123",
|
||||
amount=1000.0,
|
||||
currency="BTC",
|
||||
counterparty="counterparty1",
|
||||
timestamp=datetime.utcnow()
|
||||
)
|
||||
assert tx.transaction_id == "tx123"
|
||||
assert tx.user_id == "user123"
|
||||
assert tx.amount == 1000.0
|
||||
assert tx.currency == "BTC"
|
||||
assert tx.counterparty == "counterparty1"
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_calculate_transaction_risk_low():
|
||||
"""Test risk calculation for low risk transaction"""
|
||||
tx = TransactionMonitoring(
|
||||
transaction_id="tx123",
|
||||
user_id="user123",
|
||||
amount=50.0,
|
||||
currency="BTC",
|
||||
counterparty="counterparty1",
|
||||
timestamp=datetime(2026, 1, 1, 10, 0, 0) # Business hours
|
||||
)
|
||||
risk = calculate_transaction_risk(tx)
|
||||
assert risk == "low"
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_calculate_transaction_risk_medium():
|
||||
"""Test risk calculation for medium risk transaction"""
|
||||
tx = TransactionMonitoring(
|
||||
transaction_id="tx123",
|
||||
user_id="user123",
|
||||
amount=5000.0,
|
||||
currency="BTC",
|
||||
counterparty="counterparty1",
|
||||
timestamp=datetime(2026, 1, 1, 10, 0, 0)
|
||||
)
|
||||
risk = calculate_transaction_risk(tx)
|
||||
assert risk == "medium"
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_calculate_transaction_risk_high():
|
||||
"""Test risk calculation for high risk transaction"""
|
||||
tx = TransactionMonitoring(
|
||||
transaction_id="tx123",
|
||||
user_id="user123",
|
||||
amount=20000.0,
|
||||
currency="BTC",
|
||||
counterparty="counterparty1",
|
||||
timestamp=datetime(2026, 1, 1, 8, 0, 0) # Outside business hours
|
||||
)
|
||||
risk = calculate_transaction_risk(tx)
|
||||
assert risk == "high"
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_check_suspicious_patterns_high_value():
|
||||
"""Test suspicious pattern detection for high value"""
|
||||
tx = TransactionMonitoring(
|
||||
transaction_id="tx123",
|
||||
user_id="user123",
|
||||
amount=100000.0,
|
||||
currency="BTC",
|
||||
counterparty="counterparty1",
|
||||
timestamp=datetime.utcnow()
|
||||
)
|
||||
flags = check_suspicious_patterns(tx)
|
||||
assert "high_value_transaction" in flags
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_check_suspicious_patterns_high_risk_counterparty():
|
||||
"""Test suspicious pattern detection for high risk counterparty"""
|
||||
tx = TransactionMonitoring(
|
||||
transaction_id="tx123",
|
||||
user_id="user123",
|
||||
amount=1000.0,
|
||||
currency="BTC",
|
||||
counterparty="high_risk_entity_1",
|
||||
timestamp=datetime.utcnow()
|
||||
)
|
||||
flags = check_suspicious_patterns(tx)
|
||||
assert "high_risk_counterparty" in flags
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_check_suspicious_patterns_none():
|
||||
"""Test suspicious pattern detection with no flags"""
|
||||
tx = TransactionMonitoring(
|
||||
transaction_id="tx123",
|
||||
user_id="user123",
|
||||
amount=1000.0,
|
||||
currency="BTC",
|
||||
counterparty="safe_counterparty",
|
||||
timestamp=datetime.utcnow()
|
||||
)
|
||||
flags = check_suspicious_patterns(tx)
|
||||
assert len(flags) == 0
|
||||
Reference in New Issue
Block a user