mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-11-29 11:57:44 -05:00
Require types in tests.storage. (#14646)
Adds missing type hints to `tests.storage` package and does not allow untyped definitions.
This commit is contained in:
parent
94bc21e69f
commit
3ac412b4e2
36 changed files with 489 additions and 341 deletions
|
|
@ -14,10 +14,15 @@
|
|||
from typing import List
|
||||
from unittest import mock
|
||||
|
||||
from twisted.test.proto_helpers import MemoryReactor
|
||||
|
||||
from synapse.app.generic_worker import GenericWorkerServer
|
||||
from synapse.server import HomeServer
|
||||
from synapse.storage.database import LoggingDatabaseConnection
|
||||
from synapse.storage.prepare_database import PrepareDatabaseException, prepare_database
|
||||
from synapse.storage.schema import SCHEMA_VERSION
|
||||
from synapse.types import JsonDict
|
||||
from synapse.util import Clock
|
||||
|
||||
from tests.unittest import HomeserverTestCase
|
||||
|
||||
|
|
@ -39,13 +44,13 @@ def fake_listdir(filepath: str) -> List[str]:
|
|||
|
||||
|
||||
class WorkerSchemaTests(HomeserverTestCase):
|
||||
def make_homeserver(self, reactor, clock):
|
||||
def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer:
|
||||
hs = self.setup_test_homeserver(
|
||||
federation_http_client=None, homeserver_to_use=GenericWorkerServer
|
||||
)
|
||||
return hs
|
||||
|
||||
def default_config(self):
|
||||
def default_config(self) -> JsonDict:
|
||||
conf = super().default_config()
|
||||
|
||||
# Mark this as a worker app.
|
||||
|
|
@ -53,7 +58,7 @@ class WorkerSchemaTests(HomeserverTestCase):
|
|||
|
||||
return conf
|
||||
|
||||
def test_rolling_back(self):
|
||||
def test_rolling_back(self) -> None:
|
||||
"""Test that workers can start if the DB is a newer schema version"""
|
||||
|
||||
db_pool = self.hs.get_datastores().main.db_pool
|
||||
|
|
@ -70,7 +75,7 @@ class WorkerSchemaTests(HomeserverTestCase):
|
|||
|
||||
prepare_database(db_conn, db_pool.engine, self.hs.config)
|
||||
|
||||
def test_not_upgraded_old_schema_version(self):
|
||||
def test_not_upgraded_old_schema_version(self) -> None:
|
||||
"""Test that workers don't start if the DB has an older schema version"""
|
||||
db_pool = self.hs.get_datastores().main.db_pool
|
||||
db_conn = LoggingDatabaseConnection(
|
||||
|
|
@ -87,7 +92,7 @@ class WorkerSchemaTests(HomeserverTestCase):
|
|||
with self.assertRaises(PrepareDatabaseException):
|
||||
prepare_database(db_conn, db_pool.engine, self.hs.config)
|
||||
|
||||
def test_not_upgraded_current_schema_version_with_outstanding_deltas(self):
|
||||
def test_not_upgraded_current_schema_version_with_outstanding_deltas(self) -> None:
|
||||
"""
|
||||
Test that workers don't start if the DB is on the current schema version,
|
||||
but there are still outstanding delta migrations to run.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue