mirror of
https://github.com/saphid/frame-control.git
synced 2026-10-15 06:01:54 +02:00
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>
37 lines
1.7 KiB
Python
37 lines
1.7 KiB
Python
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)
|