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/plugin-marketplace/tests/__init__.py
Normal file
1
apps/plugin-marketplace/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Plugin marketplace service tests"""
|
||||
@@ -0,0 +1,176 @@
|
||||
"""Edge case and error handling tests for plugin marketplace service"""
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
from main import app, MarketplaceReview, PluginPurchase, DeveloperApplication, reviews, purchases, developer_applications
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def reset_state():
|
||||
"""Reset global state before each test"""
|
||||
reviews.clear()
|
||||
purchases.clear()
|
||||
developer_applications.clear()
|
||||
yield
|
||||
reviews.clear()
|
||||
purchases.clear()
|
||||
developer_applications.clear()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_marketplace_review_out_of_range_rating():
|
||||
"""Test MarketplaceReview with out of range rating"""
|
||||
review = MarketplaceReview(
|
||||
plugin_id="plugin_123",
|
||||
user_id="user_123",
|
||||
rating=10,
|
||||
title="Great plugin",
|
||||
content="Excellent"
|
||||
)
|
||||
assert review.rating == 10
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_marketplace_review_zero_rating():
|
||||
"""Test MarketplaceReview with zero rating"""
|
||||
review = MarketplaceReview(
|
||||
plugin_id="plugin_123",
|
||||
user_id="user_123",
|
||||
rating=0,
|
||||
title="Bad plugin",
|
||||
content="Poor"
|
||||
)
|
||||
assert review.rating == 0
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_marketplace_review_negative_rating():
|
||||
"""Test MarketplaceReview with negative rating"""
|
||||
review = MarketplaceReview(
|
||||
plugin_id="plugin_123",
|
||||
user_id="user_123",
|
||||
rating=-5,
|
||||
title="Terrible",
|
||||
content="Worst"
|
||||
)
|
||||
assert review.rating == -5
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_marketplace_review_empty_fields():
|
||||
"""Test MarketplaceReview with empty fields"""
|
||||
review = MarketplaceReview(
|
||||
plugin_id="",
|
||||
user_id="",
|
||||
rating=3,
|
||||
title="",
|
||||
content=""
|
||||
)
|
||||
assert review.plugin_id == ""
|
||||
assert review.title == ""
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_plugin_purchase_zero_price():
|
||||
"""Test PluginPurchase with zero price"""
|
||||
purchase = PluginPurchase(
|
||||
plugin_id="plugin_123",
|
||||
user_id="user_123",
|
||||
price=0.0,
|
||||
payment_method="free"
|
||||
)
|
||||
assert purchase.price == 0.0
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_developer_application_empty_fields():
|
||||
"""Test DeveloperApplication with empty fields"""
|
||||
application = DeveloperApplication(
|
||||
developer_name="",
|
||||
email="",
|
||||
experience="",
|
||||
description=""
|
||||
)
|
||||
assert application.developer_name == ""
|
||||
assert application.email == ""
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_popular_plugins_with_limit():
|
||||
"""Test getting popular plugins with limit parameter"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/marketplace/popular?limit=5")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "popular_plugins" in data
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_recent_plugins_with_limit():
|
||||
"""Test getting recent plugins with limit parameter"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/marketplace/recent?limit=5")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "recent_plugins" in data
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_create_multiple_reviews():
|
||||
"""Test creating multiple reviews for same plugin"""
|
||||
client = TestClient(app)
|
||||
|
||||
for i in range(3):
|
||||
review = MarketplaceReview(
|
||||
plugin_id="plugin_123",
|
||||
user_id=f"user_{i}",
|
||||
rating=5,
|
||||
title="Great",
|
||||
content="Excellent"
|
||||
)
|
||||
client.post("/api/v1/reviews", json=review.model_dump())
|
||||
|
||||
response = client.get("/api/v1/reviews/plugin_123")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["total_reviews"] == 3
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_create_multiple_purchases():
|
||||
"""Test creating multiple purchases for same plugin"""
|
||||
client = TestClient(app)
|
||||
|
||||
for i in range(3):
|
||||
purchase = PluginPurchase(
|
||||
plugin_id="plugin_123",
|
||||
user_id=f"user_{i}",
|
||||
price=99.99,
|
||||
payment_method="credit_card"
|
||||
)
|
||||
client.post("/api/v1/purchases", json=purchase.model_dump())
|
||||
|
||||
response = client.get("/api/v1/revenue/revenue_sharing")
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_developer_application_with_company():
|
||||
"""Test developer application with company"""
|
||||
client = TestClient(app)
|
||||
application = DeveloperApplication(
|
||||
developer_name="Dev Name",
|
||||
email="dev@example.com",
|
||||
company="Dev Corp",
|
||||
experience="5 years",
|
||||
description="Experienced"
|
||||
)
|
||||
response = client.post("/api/v1/developers/apply", json=application.model_dump())
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["application_id"]
|
||||
@@ -0,0 +1,165 @@
|
||||
"""Integration tests for plugin marketplace service"""
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
from main import app, MarketplaceReview, PluginPurchase, DeveloperApplication, reviews, purchases, developer_applications
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def reset_state():
|
||||
"""Reset global state before each test"""
|
||||
reviews.clear()
|
||||
purchases.clear()
|
||||
developer_applications.clear()
|
||||
yield
|
||||
reviews.clear()
|
||||
purchases.clear()
|
||||
developer_applications.clear()
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_featured_plugins_api():
|
||||
"""Test getting featured plugins API"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/marketplace/featured")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "featured_plugins" in data
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_popular_plugins_api():
|
||||
"""Test getting popular plugins API"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/marketplace/popular")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "popular_plugins" in data
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_recent_plugins_api():
|
||||
"""Test getting recent plugins API"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/marketplace/recent")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "recent_plugins" in data
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_marketplace_stats_api():
|
||||
"""Test getting marketplace stats API"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/marketplace/stats")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "stats" in data
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_create_review():
|
||||
"""Test creating a review"""
|
||||
client = TestClient(app)
|
||||
review = MarketplaceReview(
|
||||
plugin_id="plugin_123",
|
||||
user_id="user_123",
|
||||
rating=5,
|
||||
title="Great plugin",
|
||||
content="Excellent functionality"
|
||||
)
|
||||
response = client.post("/api/v1/reviews", json=review.model_dump())
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["review_id"]
|
||||
assert data["status"] == "created"
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_plugin_reviews_api():
|
||||
"""Test getting plugin reviews API"""
|
||||
client = TestClient(app)
|
||||
# Create a review first
|
||||
review = MarketplaceReview(
|
||||
plugin_id="plugin_123",
|
||||
user_id="user_123",
|
||||
rating=5,
|
||||
title="Great plugin",
|
||||
content="Excellent functionality"
|
||||
)
|
||||
client.post("/api/v1/reviews", json=review.model_dump())
|
||||
|
||||
response = client.get("/api/v1/reviews/plugin_123")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["plugin_id"] == "plugin_123"
|
||||
assert "reviews" in data
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_plugin_reviews_no_reviews():
|
||||
"""Test getting plugin reviews when no reviews exist"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/reviews/nonexistent")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["total_reviews"] == 0
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_create_purchase():
|
||||
"""Test creating a purchase"""
|
||||
client = TestClient(app)
|
||||
purchase = PluginPurchase(
|
||||
plugin_id="plugin_123",
|
||||
user_id="user_123",
|
||||
price=99.99,
|
||||
payment_method="credit_card"
|
||||
)
|
||||
response = client.post("/api/v1/purchases", json=purchase.model_dump())
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["purchase_id"]
|
||||
assert data["status"] == "completed"
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_apply_developer():
|
||||
"""Test applying to become a developer"""
|
||||
client = TestClient(app)
|
||||
application = DeveloperApplication(
|
||||
developer_name="Dev Name",
|
||||
email="dev@example.com",
|
||||
experience="5 years",
|
||||
description="Experienced developer"
|
||||
)
|
||||
response = client.post("/api/v1/developers/apply", json=application.model_dump())
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["application_id"]
|
||||
assert data["status"] == "pending"
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_verified_developers_api():
|
||||
"""Test getting verified developers API"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/developers/verified")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "verified_developers" in data
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_get_developer_revenue():
|
||||
"""Test getting developer revenue"""
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/v1/revenue/dev_123")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "total_revenue" in data
|
||||
108
apps/plugin-marketplace/tests/test_unit_plugin_marketplace.py
Normal file
108
apps/plugin-marketplace/tests/test_unit_plugin_marketplace.py
Normal file
@@ -0,0 +1,108 @@
|
||||
"""Unit tests for plugin marketplace service"""
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
from main import app, MarketplaceReview, PluginPurchase, DeveloperApplication
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_app_initialization():
|
||||
"""Test that the FastAPI app initializes correctly"""
|
||||
assert app is not None
|
||||
assert app.title == "AITBC Plugin Marketplace"
|
||||
assert app.version == "1.0.0"
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_marketplace_review_model():
|
||||
"""Test MarketplaceReview model"""
|
||||
review = MarketplaceReview(
|
||||
plugin_id="plugin_123",
|
||||
user_id="user_123",
|
||||
rating=5,
|
||||
title="Great plugin",
|
||||
content="Excellent functionality",
|
||||
pros=["Easy to use", "Fast"],
|
||||
cons=["Learning curve"]
|
||||
)
|
||||
assert review.plugin_id == "plugin_123"
|
||||
assert review.rating == 5
|
||||
assert review.title == "Great plugin"
|
||||
assert review.pros == ["Easy to use", "Fast"]
|
||||
assert review.cons == ["Learning curve"]
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_marketplace_review_defaults():
|
||||
"""Test MarketplaceReview with default values"""
|
||||
review = MarketplaceReview(
|
||||
plugin_id="plugin_123",
|
||||
user_id="user_123",
|
||||
rating=4,
|
||||
title="Good plugin",
|
||||
content="Nice functionality"
|
||||
)
|
||||
assert review.pros == []
|
||||
assert review.cons == []
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_plugin_purchase_model():
|
||||
"""Test PluginPurchase model"""
|
||||
purchase = PluginPurchase(
|
||||
plugin_id="plugin_123",
|
||||
user_id="user_123",
|
||||
price=99.99,
|
||||
payment_method="credit_card"
|
||||
)
|
||||
assert purchase.plugin_id == "plugin_123"
|
||||
assert purchase.price == 99.99
|
||||
assert purchase.payment_method == "credit_card"
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_plugin_purchase_negative_price():
|
||||
"""Test PluginPurchase with negative price"""
|
||||
purchase = PluginPurchase(
|
||||
plugin_id="plugin_123",
|
||||
user_id="user_123",
|
||||
price=-99.99,
|
||||
payment_method="credit_card"
|
||||
)
|
||||
assert purchase.price == -99.99
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_developer_application_model():
|
||||
"""Test DeveloperApplication model"""
|
||||
application = DeveloperApplication(
|
||||
developer_name="Dev Name",
|
||||
email="dev@example.com",
|
||||
company="Dev Corp",
|
||||
experience="5 years",
|
||||
portfolio_url="https://portfolio.com",
|
||||
github_username="devuser",
|
||||
description="Experienced developer"
|
||||
)
|
||||
assert application.developer_name == "Dev Name"
|
||||
assert application.email == "dev@example.com"
|
||||
assert application.company == "Dev Corp"
|
||||
assert application.github_username == "devuser"
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_developer_application_defaults():
|
||||
"""Test DeveloperApplication with optional fields"""
|
||||
application = DeveloperApplication(
|
||||
developer_name="Dev Name",
|
||||
email="dev@example.com",
|
||||
experience="3 years",
|
||||
description="New developer"
|
||||
)
|
||||
assert application.company is None
|
||||
assert application.portfolio_url is None
|
||||
assert application.github_username is None
|
||||
Reference in New Issue
Block a user