Add a make_event_from_dict method (#6858)

... and use it in places where it's trivial to do so.

This will make it easier to pass room versions into the FrozenEvent
constructors.
This commit is contained in:
Richard van der Hoff 2020-02-07 15:30:04 +00:00 committed by GitHub
parent b08b0a22d5
commit 799001f2c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 52 additions and 39 deletions

View file

@ -13,8 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from synapse.events import FrozenEvent
from synapse.events import make_event_from_dict
from synapse.events.utils import (
copy_power_levels_contents,
prune_event,
@ -30,7 +29,7 @@ def MockEvent(**kwargs):
kwargs["event_id"] = "fake_event_id"
if "type" not in kwargs:
kwargs["type"] = "fake_type"
return FrozenEvent(kwargs)
return make_event_from_dict(kwargs)
class PruneEventTestCase(unittest.TestCase):
@ -38,7 +37,9 @@ class PruneEventTestCase(unittest.TestCase):
`matchdict` when it is redacted. """
def run_test(self, evdict, matchdict):
self.assertEquals(prune_event(FrozenEvent(evdict)).get_dict(), matchdict)
self.assertEquals(
prune_event(make_event_from_dict(evdict)).get_dict(), matchdict
)
def test_minimal(self):
self.run_test(