Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Xbus emitter
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XCG
Odoo modules
Xbus emitter
Commits
b953944d8126
Commit
b953944d8126
authored
6 years ago
by
szeka.wong
Browse files
Options
Downloads
Patches
Plain Diff
Fix unit test.
parent
d204525d87dd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_xbus_emitter.py
+21
-20
21 additions, 20 deletions
tests/test_xbus_emitter.py
with
21 additions
and
20 deletions
tests/test_xbus_emitter.py
+
21
−
20
View file @
b953944d
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
from
.util.uuidgen
import
genUuid
from
.util.uuidgen
import
genUuid
import
mock
# Odoo req.
import
mock
# Odoo req.
from
unittest.mock
import
create_autospec
# Save this method so we can wrap it in a mock.
# Save this method so we can wrap it in a mock.
prev_sql_execute
=
odoo
.
sql_db
.
Cursor
.
execute
prev_sql_execute
=
odoo
.
sql_db
.
Cursor
.
execute
...
@@ -33,9 +34,7 @@
...
@@ -33,9 +34,7 @@
@odoo.tests.common.post_install
(
True
)
@odoo.tests.common.post_install
(
True
)
class
Test
(
TestBase
):
class
Test
(
TestBase
):
@mock.patch.object
(
odoo
.
sql_db
.
Cursor
,
'
execute
'
,
autospec
=
True
,
def
test_0000_create_xbus_emitter_job
(
self
):
side_effect
=
prev_sql_execute
)
def
test_0000_create_xbus_emitter_job
(
self
,
sql_execute_mock
):
"""
Basic job creation test using public methods provided by this
"""
Basic job creation test using public methods provided by this
module.
module.
"""
"""
...
@@ -39,4 +38,11 @@
...
@@ -39,4 +38,11 @@
"""
Basic job creation test using public methods provided by this
"""
Basic job creation test using public methods provided by this
module.
module.
"""
"""
with
mock
.
patch
.
object
(
self
.
env
.
cr
,
'
execute
'
,
autospec
=
True
,
side_effect
=
self
.
env
.
cr
.
execute
):
# Use the default emitter loaded by this module.
emitter
=
self
.
env
[
'
xbus.emitter
'
].
search
([],
limit
=
1
)
self
.
assertTrue
(
emitter
)
...
@@ -42,8 +48,4 @@
...
@@ -42,8 +48,4 @@
# Use the default emitter loaded by this module.
EVENT_TYPE
=
genUuid
()
emitter
=
self
.
env
[
'
xbus.emitter
'
].
search
([],
limit
=
1
)
DATA
=
{
'
foo
'
:
'
bar
'
}
self
.
assertTrue
(
emitter
)
EVENT_TYPE
=
genUuid
()
DATA
=
{
'
foo
'
:
'
bar
'
}
...
@@ -49,8 +51,8 @@
...
@@ -49,8 +51,8 @@
job
=
emitter
.
send_items
(
EVENT_TYPE
,
DATA
)
job
=
emitter
.
send_items
(
EVENT_TYPE
,
DATA
)
self
.
assertTrue
(
job
)
self
.
assertTrue
(
job
)
self
.
assertEqual
(
job
.
event_type
,
EVENT_TYPE
)
self
.
assertEqual
(
job
.
event_type
,
EVENT_TYPE
)
self
.
assertFalse
(
job
.
log
)
# Not processed yet.
self
.
assertFalse
(
job
.
log
)
# Not processed yet.
self
.
assertEqual
(
job
.
items
,
'
{
"
foo
"
:
"
bar
"
}
'
)
# JSON-ified
self
.
assertEqual
(
job
.
items
,
'
{
"
foo
"
:
"
bar
"
}
'
)
# JSON-ified
self
.
assertEqual
(
job
.
state
,
'
to_send
'
)
self
.
assertEqual
(
job
.
state
,
'
to_send
'
)
...
@@ -56,6 +58,5 @@
...
@@ -56,6 +58,5 @@
# Ensure a "NOTIFY" postgresql command has been sent.
# Ensure a "NOTIFY" postgresql command has been sent.
sql_execute_mock
.
assert_any_call
(
self
.
env
.
cr
.
execute
.
assert_any_call
(
self
.
env
.
cr
,
"
NOTIFY xbus_emitter_job,
'
%s
'"
%
emitter
.
id
,
"
NOTIFY xbus_emitter_job,
'
%s
'"
%
job
.
id
,
)
)
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