Spaces:
Running
Running
File size: 2,583 Bytes
212d694 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
import unittest
from mediaunmasked.analyzers.scoring import MediaScorer
import logging
class TestMediaScorer(unittest.TestCase):
def setUp(self):
self.scorer = MediaScorer()
logging.basicConfig(level=logging.INFO)
self.logger = logging.getLogger(__name__)
def test_high_quality_article(self):
"""Test scoring of high-quality article"""
headline = "New Study Shows Link Between Exercise and Mental Health"
content = """According to research published in the Journal of Medicine, regular
exercise significantly improves mental health outcomes. The study, conducted over
two years with 1000 participants, found a 30% reduction in anxiety symptoms among
those who exercised regularly. Dr. Smith, lead researcher, stated that the findings
demonstrate a clear correlation between physical activity and mental wellbeing."""
result = self.scorer.calculate_media_score(headline, content)
self.assertIsNotNone(result)
self.assertGreater(result['media_unmasked_score'], 80)
self.assertEqual(result['rating'], 'Trustworthy')
self.logger.info(f"High quality article score: {result}")
def test_biased_article(self):
"""Test scoring of biased article"""
headline = "Government Policies Destroying Our Way of Life"
content = """Experts say the radical new policies are ruining everything!
Sources claim this is the worst decision ever made. Many believe this will
lead to disaster. The socialist agenda is clearly destroying our values."""
result = self.scorer.calculate_media_score(headline, content)
self.assertIsNotNone(result)
self.assertLess(result['media_unmasked_score'], 60)
self.assertEqual(result['rating'], 'Bias Present')
self.logger.info(f"Biased article score: {result}")
def test_misleading_article(self):
"""Test scoring of misleading article"""
headline = "Miracle Cure Found for All Diseases!"
content = """Some people say this amazing discovery cures everything!
You won't believe the shocking results. Everyone knows this is the
breakthrough we've been waiting for!"""
result = self.scorer.calculate_media_score(headline, content)
self.assertIsNotNone(result)
self.assertLess(result['media_unmasked_score'], 50)
self.assertEqual(result['rating'], 'Misleading')
self.logger.info(f"Misleading article score: {result}") |