Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
11e6b3d1
Commit
11e6b3d1
authored
10 years ago
by
Kegan Dougal
Browse files
Options
Downloads
Patches
Plain Diff
Dependency inject ApplicationServiceApi when creating ApplicationServicesHandler.
parent
a3c60107
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
synapse/handlers/__init__.py
+4
-1
4 additions, 1 deletion
synapse/handlers/__init__.py
synapse/handlers/appservice.py
+2
-3
2 additions, 3 deletions
synapse/handlers/appservice.py
tests/handlers/test_appservice.py
+3
-7
3 additions, 7 deletions
tests/handlers/test_appservice.py
with
9 additions
and
11 deletions
synapse/handlers/__init__.py
+
4
−
1
View file @
11e6b3d1
...
...
@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
synapse.appservice.api
import
ApplicationServiceApi
from
.register
import
RegistrationHandler
from
.room
import
(
RoomCreationHandler
,
RoomMemberHandler
,
RoomListHandler
...
...
@@ -53,5 +54,7 @@ class Handlers(object):
self
.
directory_handler
=
DirectoryHandler
(
hs
)
self
.
typing_notification_handler
=
TypingNotificationHandler
(
hs
)
self
.
admin_handler
=
AdminHandler
(
hs
)
self
.
appservice_handler
=
ApplicationServicesHandler
(
hs
)
self
.
appservice_handler
=
ApplicationServicesHandler
(
hs
,
ApplicationServiceApi
(
hs
)
)
self
.
sync_handler
=
SyncHandler
(
hs
)
This diff is collapsed.
Click to expand it.
synapse/handlers/appservice.py
+
2
−
3
View file @
11e6b3d1
...
...
@@ -18,7 +18,6 @@ from twisted.internet import defer
from
synapse.api.constants
import
EventTypes
from
synapse.api.errors
import
Codes
,
StoreError
,
SynapseError
from
synapse.appservice
import
ApplicationService
from
synapse.appservice.api
import
ApplicationServiceApi
from
synapse.types
import
UserID
import
synapse.util.stringutils
as
stringutils
...
...
@@ -32,10 +31,10 @@ logger = logging.getLogger(__name__)
# easier.
class
ApplicationServicesHandler
(
object
):
def
__init__
(
self
,
hs
):
def
__init__
(
self
,
hs
,
appservice_api
):
self
.
store
=
hs
.
get_datastore
()
self
.
hs
=
hs
self
.
appservice_api
=
A
pp
licationServiceApi
(
hs
)
self
.
appservice_api
=
a
pp
service_api
@defer.inlineCallbacks
def
register
(
self
,
app_service
):
...
...
This diff is collapsed.
Click to expand it.
tests/handlers/test_appservice.py
+
3
−
7
View file @
11e6b3d1
...
...
@@ -29,13 +29,9 @@ class AppServiceHandlerTestCase(unittest.TestCase):
self
.
mock_as_api
=
Mock
()
hs
=
Mock
()
hs
.
get_datastore
=
Mock
(
return_value
=
self
.
mock_store
)
self
.
handler
=
ApplicationServicesHandler
(
hs
)
# thing being tested
# FIXME Would be nice to DI this rather than monkey patch:(
if
not
hasattr
(
self
.
handler
,
"
appservice_api
"
):
# someone probably updated the handler but not the tests. Fail fast.
raise
Exception
(
"
Test expected handler.appservice_api to exist.
"
)
self
.
handler
.
appservice_api
=
self
.
mock_as_api
self
.
handler
=
ApplicationServicesHandler
(
hs
,
self
.
mock_as_api
)
@defer.inlineCallbacks
def
test_notify_interested_services
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment