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
08f5c48f
Commit
08f5c48f
authored
10 years ago
by
Paul "LeoNerd" Evans
Browse files
Options
Downloads
Patches
Plain Diff
Move SQLiteMemoryDbPool implementation into tests.utils
parent
9774949c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/storage/test_profile.py
+1
-27
1 addition, 27 deletions
tests/storage/test_profile.py
tests/utils.py
+14
-0
14 additions, 0 deletions
tests/utils.py
with
15 additions
and
27 deletions
tests/storage/test_profile.py
+
1
−
27
View file @
08f5c48f
...
@@ -18,38 +18,12 @@ from twisted.trial import unittest
...
@@ -18,38 +18,12 @@ from twisted.trial import unittest
from
twisted.internet
import
defer
from
twisted.internet
import
defer
from
mock
import
Mock
,
call
from
mock
import
Mock
,
call
from
twisted.enterprise.adbapi
import
ConnectionPool
from
synapse.server
import
HomeServer
from
synapse.server
import
HomeServer
from
synapse.storage
import
prepare_database
from
synapse.storage
import
prepare_database
from
synapse.storage.profile
import
ProfileStore
from
synapse.storage.profile
import
ProfileStore
from
tests.utils
import
SQLiteMemoryDbPool
class
SQLiteMemoryDbPool
(
ConnectionPool
,
object
):
def
__init__
(
self
):
super
(
SQLiteMemoryDbPool
,
self
).
__init__
(
"
sqlite3
"
,
"
:memory:
"
,
cp_min
=
1
,
cp_max
=
1
,
)
def
prepare
(
self
):
return
self
.
runWithConnection
(
prepare_database
)
#def runInteraction(self, interaction, *args, **kwargs):
# # Just use a cursor as the txn directly
# txn = self.db.cursor()
# def _on_success(result):
# txn.commit()
# return result
# def _on_failure(failure):
# txn.rollback()
# raise failure
# d = interaction(txn, *args, **kwargs)
# d.addCallbacks(_on_success, _on_failure)
# return d
class
ProfileStoreTestCase
(
unittest
.
TestCase
):
class
ProfileStoreTestCase
(
unittest
.
TestCase
):
...
...
This diff is collapsed.
Click to expand it.
tests/utils.py
+
14
−
0
View file @
08f5c48f
...
@@ -16,12 +16,14 @@
...
@@ -16,12 +16,14 @@
from
synapse.http.server
import
HttpServer
from
synapse.http.server
import
HttpServer
from
synapse.api.errors
import
cs_error
,
CodeMessageException
,
StoreError
from
synapse.api.errors
import
cs_error
,
CodeMessageException
,
StoreError
from
synapse.api.constants
import
Membership
from
synapse.api.constants
import
Membership
from
synapse.storage
import
prepare_database
from
synapse.api.events.room
import
(
from
synapse.api.events.room
import
(
RoomMemberEvent
,
MessageEvent
RoomMemberEvent
,
MessageEvent
)
)
from
twisted.internet
import
defer
,
reactor
from
twisted.internet
import
defer
,
reactor
from
twisted.enterprise.adbapi
import
ConnectionPool
from
collections
import
namedtuple
from
collections
import
namedtuple
from
mock
import
patch
,
Mock
from
mock
import
patch
,
Mock
...
@@ -120,6 +122,18 @@ class MockClock(object):
...
@@ -120,6 +122,18 @@ class MockClock(object):
self
.
now
+=
secs
self
.
now
+=
secs
class
SQLiteMemoryDbPool
(
ConnectionPool
,
object
):
def
__init__
(
self
):
super
(
SQLiteMemoryDbPool
,
self
).
__init__
(
"
sqlite3
"
,
"
:memory:
"
,
cp_min
=
1
,
cp_max
=
1
,
)
def
prepare
(
self
):
return
self
.
runWithConnection
(
prepare_database
)
class
MemoryDataStore
(
object
):
class
MemoryDataStore
(
object
):
Room
=
namedtuple
(
Room
=
namedtuple
(
...
...
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