moderation preview of pictures and audio files
Sonarqube Scanner / Prepare environment (push) Successful in 9s
Sonarqube Scanner / Build and test (push) Successful in 26s
Sonarqube Scanner / SonarQube analysis (push) Successful in 1m11s
Sonarqube Scanner / Deploy to Server (push) Successful in 8s

This commit is contained in:
Florian Zumpe
2026-10-03 15:48:04 +02:00
parent 94793b530d
commit 4b8bdcad5f
7 changed files with 209 additions and 8 deletions
+31
View File
@@ -114,6 +114,37 @@ class ModerationTests(unittest.TestCase):
self.assertEqual(self.run_cli([]), 0)
self.assertIn("Keine Strecken", self.out.getvalue())
def test_station_table_has_ordered_media_links_without_database_writes(self):
with sqlite3.connect(self.path) as database:
database.execute("INSERT INTO pois (route_id, title, description, sequence, audio_path) VALUES (1, 'Ton', 'Erste\nStation', 9, 'active/routes/1/audio/a.mp3')")
database.execute("INSERT INTO pois (route_id, title, description, sequence) VALUES (1, 'Bild', 'Zweite', 3)")
database.execute("INSERT INTO poi_images (poi_id, path) VALUES (2, 'active/routes/1/images/a.png')")
database.execute("INSERT INTO pois (route_id, title, sequence) VALUES (1, 'Ohne Medien', 12)")
database.execute("INSERT INTO pois (route_id, title, audio_path) VALUES (2, 'Gelöscht', 'trash/routes/2/audio/a.mp3')")
(self.root / '.env').write_text('MODERATION_REVIEW_URL=https://wegwichtel.de/moderation/api/\n')
before = self.path.read_bytes()
self.assertEqual(self.run_cli([]), 0)
output = self.out.getvalue()
self.assertIn('Beschreibung', output)
self.assertIn('Erste Station', output)
self.assertRegex(output, r'2\s+\| 1\s+\| Zweite')
self.assertIn('https://wegwichtel.de/moderation/api/routes/1/pois/2/pictures/1', output)
self.assertIn('https://wegwichtel.de/moderation/api/routes/1/pois/1/audio', output)
self.assertNotIn('/routes/2/pois/', output)
self.assertEqual(self.path.read_bytes(), before)
self.out.seek(0)
self.out.truncate()
self.assertEqual(self.run_cli([]), 0)
self.assertEqual(output, self.out.getvalue())
def test_invalid_review_configuration(self):
for setting in ['MODERATION_REVIEW_URL=http://example.com/review',
'MODERATION_REVIEW_URL=https://example.com/review?token=x',
'MODERATION_REVIEW_URL=https://user:password@example.com/review',
'MODERATION_REVIEW_URL="https://example.com/review#fragment"']:
(self.root / '.env').write_text(setting)
self.assertEqual(self.run_cli([]), 1)
def test_invalid_arguments(self):
for args in [["-e", "0"], ["-d", "abc"], ["-e", "1", "-d", "1"], ["-e"]]:
with redirect_stderr(self.error), self.assertRaises(SystemExit) as result: