Files
saphid--frame-control/tests/test_sidequest.py
T
saphidandClaude Opus 5.5 f1aaed6279 Tests: keep every test (and the servers they start) off the real ~/.ssh
Servers started by test_server's OneServer and LocalMode tests got no
FRAME_CONTROL_SSH_DIR, so each one imported the real ~/.ssh/config into a
fresh throwaway devices.json and seeded a pin into the real
~/.ssh/frame-control-hosts: about a dozen files per suite run.

tests/sandbox.py now gives the whole run a throwaway HOME/USERPROFILE and
FRAME_CONTROL_SSH_DIR (inherited by child processes), every test module
imports it first, and frame_connect.SSH_DIR honours FRAME_CONTROL_SSH_DIR
like frame_devices.ssh_dir(). test_sandbox checks the paths and reruns the
tests that leaked from the original environment, asserting nothing under
the real ~/.ssh changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 15:40:01 +11:00

37 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import sandbox # noqa: F401 (first: keeps tests off real data and services)
import json
from pathlib import Path
import sys
import unittest
from unittest.mock import patch
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'ui'))
from apk_sources import SourceError, sidequest
class SideQuestTests(unittest.TestCase):
def test_policy_is_recorded_and_source_is_page_only(self):
fixture = json.loads((Path(__file__).parent / 'fixtures/sidequest-policy.json').read_text())
self.assertIn('/search/', fixture['robots']['disallow'])
self.assertIn('scraping', fixture['terms']['prohibited_activities_i'])
self.assertTrue(sidequest.sources()[0]['page_only'])
@patch('urllib.request.urlopen', side_effect=AssertionError('network forbidden'))
def test_unknown_listing_never_claims_free_or_downloadable(self, _urlopen):
source = sidequest.sources()[0]
entry = sidequest.details(source, '123')
self.assertEqual(entry['page'], 'https://sidequestvr.com/app/123')
self.assertFalse(entry['downloadable'])
self.assertIsNone(entry['free'])
self.assertIsNone(entry['vr'])
self.assertEqual(entry['images']['screenshots'], [])
with self.assertRaisesRegex(SourceError, 'page-only'):
sidequest.download(source, '123')
self.assertEqual(sidequest.search(source, 'open saber'), [])
self.assertEqual(sidequest.search(source, 'open saber', 0), [])
def test_invalid_ids(self):
for value in ('../123', '1?paid=false', '1', '', '1/2', '1' * 13):
with self.assertRaises(SourceError):
sidequest.details(sidequest.sources()[0], value)