test: raise coverage 68.7% -> ~80.4%; add ~250 tests for new egress/DDNS/network paths
Unit Tests / test (push) Successful in 12m6s

Coverage was below acceptable levels and several newly-added code paths
(sshuttle egress, proxy egress, DDNS provider stubs, DNS overview route,
peer-registry provisioning) had zero test coverage.

~250 new unit tests are added across 16 new test files. Existing test files
are updated to match refactored interfaces (DHCP removed, constants
introduced, network_manager restructured). .coveragerc is added to pin the
source mapping and the 70% floor so regressions are caught at commit time.

tests/test_enhanced_api.py was previously living in api/ (wrong location)
and is moved to tests/ where it belongs.

Integration test files are updated to remove references to DHCP endpoints
and add coverage for the new DNS overview and DDNS sync endpoints.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 09:03:39 -04:00
parent c41cadafb4
commit aa1e5c41ec
33 changed files with 9446 additions and 631 deletions
+24
View File
@@ -169,5 +169,29 @@ class TestDdnsRegister(unittest.TestCase):
self.assertTrue(body['registered'])
self.assertEqual(body['subdomain'], 'mypic.pic.ngo')
class TestDdnsSyncRecords(unittest.TestCase):
def setUp(self):
self.client = _make_client()
def test_sync_success(self):
from app import ddns_manager
with patch.object(ddns_manager, 'sync_service_records',
return_value={'success': True, 'synced': ['a'], 'failed': []}):
r = self.client.post('/api/ddns/sync')
self.assertEqual(r.status_code, 200)
self.assertTrue(json.loads(r.data)['success'])
def test_sync_ddns_error_returns_400(self):
from app import ddns_manager
from ddns_manager import DDNSError
with patch.object(ddns_manager, 'sync_service_records',
side_effect=DDNSError('no provider')):
r = self.client.post('/api/ddns/sync')
self.assertEqual(r.status_code, 400)
self.assertIn('error', json.loads(r.data))
if __name__ == '__main__':
unittest.main()