Create tests/test_services.py
Browse files- app/tests/test_services.py +20 -0
app/tests/test_services.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
from app.services.ai_processor import AIPipeline
|
| 3 |
+
from app.services.scraper import FacebookScraper
|
| 4 |
+
|
| 5 |
+
def test_ai_processor():
|
| 6 |
+
ai = AIPipeline()
|
| 7 |
+
result = ai.process_ad("This is a positive ad!")
|
| 8 |
+
assert "sentiment" in result
|
| 9 |
+
|
| 10 |
+
def test_scraper():
|
| 11 |
+
scraper = FacebookScraper()
|
| 12 |
+
ads = scraper.scrape_ads("test query", num_scrolls=1)
|
| 13 |
+
assert isinstance(ads, list)
|
| 14 |
+
|
| 15 |
+
def test_blockchain():
|
| 16 |
+
from app.services.blockchain import AdBlockchain
|
| 17 |
+
blockchain = AdBlockchain()
|
| 18 |
+
block = blockchain.create_block(proof=123, previous_hash="abc")
|
| 19 |
+
assert block["index"] == 2
|
| 20 |
+
assert blockchain.is_chain_valid()
|