Mercurial > libervia-backend
diff sat/test/test_plugin_xep_0313.py @ 4037:524856bd7b19
massive refactoring to switch from camelCase to snake_case:
historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a
pre-PEP8 code, to use the same coding style as in Twisted.
However, snake_case is more readable and it's better to follow PEP8 best practices, so it
has been decided to move on full snake_case. Because Libervia has a huge codebase, this
ended with a ugly mix of camelCase and snake_case.
To fix that, this patch does a big refactoring by renaming every function and method
(including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case.
This is a massive change, and may result in some bugs.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 08 Apr 2023 13:54:42 +0200 |
parents | be6d91572633 |
children |
line wrap: on
line diff
--- a/sat/test/test_plugin_xep_0313.py Fri Apr 07 15:18:39 2023 +0200 +++ b/sat/test/test_plugin_xep_0313.py Sat Apr 08 13:54:42 2023 +0200 @@ -42,11 +42,11 @@ def setUp(self): self.host = helpers.FakeSAT() self.plugin = XEP_0313(self.host) - self.client = self.host.getClient(C.PROFILE[0]) - mam_client = self.plugin.getHandler(C.PROFILE[0]) - mam_client.makeConnection(self.host.getClient(C.PROFILE[0]).xmlstream) + self.client = self.host.get_client(C.PROFILE[0]) + mam_client = self.plugin.get_handler(C.PROFILE[0]) + mam_client.makeConnection(self.host.get_client(C.PROFILE[0]).xmlstream) - def test_queryArchive(self): + def test_query_archive(self): xml = """ <iq type='set' id='%s' to='%s'> <query xmlns='urn:xmpp:mam:1'/> @@ -57,11 +57,11 @@ ) d = self.plugin.queryArchive(self.client, MAMRequest(), SERVICE_JID) d.addCallback( - lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) + lambda __: self.assert_equal_xml(self.host.get_sent_message_xml(0), xml, True) ) return d - def test_queryArchivePubsub(self): + def test_query_archive_pubsub(self): xml = """ <iq type='set' id='%s' to='%s'> <query xmlns='urn:xmpp:mam:1' node='fdp/submitted/capulet.lit/sonnets' /> @@ -74,11 +74,11 @@ self.client, MAMRequest(node="fdp/submitted/capulet.lit/sonnets"), SERVICE_JID ) d.addCallback( - lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) + lambda __: self.assert_equal_xml(self.host.get_sent_message_xml(0), xml, True) ) return d - def test_queryArchiveWith(self): + def test_query_archive_with(self): xml = """ <iq type='set' id='%s' to='%s'> <query xmlns='urn:xmpp:mam:1'> @@ -99,11 +99,11 @@ form = buildForm(with_jid=JID("juliet@capulet.lit")) d = self.plugin.queryArchive(self.client, MAMRequest(form), SERVICE_JID) d.addCallback( - lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) + lambda __: self.assert_equal_xml(self.host.get_sent_message_xml(0), xml, True) ) return d - def test_queryArchiveStartEnd(self): + def test_query_archive_start_end(self): xml = """ <iq type='set' id='%s' to='%s'> <query xmlns='urn:xmpp:mam:1'> @@ -129,11 +129,11 @@ form = buildForm(start=start, end=end) d = self.plugin.queryArchive(self.client, MAMRequest(form), SERVICE_JID) d.addCallback( - lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) + lambda __: self.assert_equal_xml(self.host.get_sent_message_xml(0), xml, True) ) return d - def test_queryArchiveStart(self): + def test_query_archive_start(self): xml = """ <iq type='set' id='%s' to='%s'> <query xmlns='urn:xmpp:mam:1'> @@ -155,11 +155,11 @@ form = buildForm(start=start) d = self.plugin.queryArchive(self.client, MAMRequest(form), SERVICE_JID) d.addCallback( - lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) + lambda __: self.assert_equal_xml(self.host.get_sent_message_xml(0), xml, True) ) return d - def test_queryArchiveRSM(self): + def test_query_archive_rsm(self): xml = """ <iq type='set' id='%s' to='%s'> <query xmlns='urn:xmpp:mam:1'> @@ -185,11 +185,11 @@ rsm = RSMRequest(max_=10) d = self.plugin.queryArchive(self.client, MAMRequest(form, rsm), SERVICE_JID) d.addCallback( - lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) + lambda __: self.assert_equal_xml(self.host.get_sent_message_xml(0), xml, True) ) return d - def test_queryArchiveRSMPaging(self): + def test_query_archive_rsm_paging(self): xml = """ <iq type='set' id='%s' to='%s'> <query xmlns='urn:xmpp:mam:1'> @@ -212,11 +212,11 @@ rsm = RSMRequest(max_=10, after="09af3-cc343-b409f") d = self.plugin.queryArchive(self.client, MAMRequest(form, rsm), SERVICE_JID) d.addCallback( - lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) + lambda __: self.assert_equal_xml(self.host.get_sent_message_xml(0), xml, True) ) return d - def test_queryFields(self): + def test_query_fields(self): xml = """ <iq type='get' id="%s" to='%s'> <query xmlns='urn:xmpp:mam:1'/> @@ -227,11 +227,11 @@ ) d = self.plugin.queryFields(self.client, SERVICE_JID) d.addCallback( - lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) + lambda __: self.assert_equal_xml(self.host.get_sent_message_xml(0), xml, True) ) return d - def test_queryArchiveFields(self): + def test_query_archive_fields(self): xml = """ <iq type='set' id='%s' to='%s'> <query xmlns='urn:xmpp:mam:1'> @@ -267,11 +267,11 @@ form = buildForm(extra_fields=extra_fields) d = self.plugin.queryArchive(self.client, MAMRequest(form), SERVICE_JID) d.addCallback( - lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) + lambda __: self.assert_equal_xml(self.host.get_sent_message_xml(0), xml, True) ) return d - def test_queryPrefs(self): + def test_query_prefs(self): xml = """ <iq type='get' id='%s' to='%s'> <prefs xmlns='urn:xmpp:mam:1'> @@ -283,13 +283,13 @@ ("H_%d" % domish.Element._idCounter), SERVICE, ) - d = self.plugin.getPrefs(self.client, SERVICE_JID) + d = self.plugin.get_prefs(self.client, SERVICE_JID) d.addCallback( - lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) + lambda __: self.assert_equal_xml(self.host.get_sent_message_xml(0), xml, True) ) return d - def test_setPrefs(self): + def test_set_prefs(self): xml = """ <iq type='set' id='%s' to='%s'> <prefs xmlns='urn:xmpp:mam:1' default='roster'> @@ -309,6 +309,6 @@ never = [JID("montague@montague.lit")] d = self.plugin.setPrefs(self.client, SERVICE_JID, always=always, never=never) d.addCallback( - lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) + lambda __: self.assert_equal_xml(self.host.get_sent_message_xml(0), xml, True) ) return d