Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
6
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
X
xivo-dao
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Labels
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xivo.solutions
xivo-dao
Commits
b98d44d6
Commit
b98d44d6
authored
Jul 09, 2020
by
Laurent Meiller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3389 Add create dao action
parent
1436bd3a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
xivo_dao/resources/labels/dao.py
xivo_dao/resources/labels/dao.py
+4
-0
xivo_dao/resources/labels/tests/test_dao.py
xivo_dao/resources/labels/tests/test_dao.py
+10
-0
No files found.
xivo_dao/resources/labels/dao.py
View file @
b98d44d6
...
...
@@ -34,6 +34,10 @@ def get(label_id):
query
=
Session
.
query
(
Labels
).
filter_by
(
id
=
label_id
)
return
query
.
first
()
def
create
(
label
):
Session
.
add
(
label
)
Session
.
flush
()
return
label
def
search
(
**
parameters
):
rows
,
total
=
label_search
.
search
(
Session
,
parameters
)
...
...
xivo_dao/resources/labels/tests/test_dao.py
View file @
b98d44d6
...
...
@@ -20,6 +20,7 @@ from xivo_dao.resources.utils.search import SearchResult
from
xivo_dao.tests.test_dao
import
DAOTestCase
from
xivo_dao.resources.labels
import
dao
as
label_dao
from
xivo_dao.resources.user
import
dao
as
user_dao
from
xivo_dao.alchemy.labels
import
Labels
class
TestLabelExist
(
DAOTestCase
):
...
...
@@ -47,6 +48,15 @@ class TestLabelExist(DAOTestCase):
assert_that
(
result
[
1
][
0
].
users_count
,
equal_to
(
0
))
assert_that
(
result
,
equal_to
(
expected
))
def
test_create_label
(
self
):
props
=
{
'display_name'
:
'MyLabel'
,
'description'
:
'Any Label'
}
label
=
label_dao
.
create
(
Labels
(
**
props
))
expected
=
label_dao
.
get
(
label
.
id
)
assert_that
(
label
,
equal_to
(
expected
))
def
test_get_all_labels_with_associated_user
(
self
):
label_row
=
self
.
add_label
()
user
=
self
.
add_user
(
callerid
=
'"John Doe"'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment