Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyOTRS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Coopdevs
Som Connexió
OTRS
PyOTRS
Commits
31514966
Commit
31514966
authored
8 years ago
by
Robert Habermann
Browse files
Options
Downloads
Patches
Plain Diff
restore most changes
parent
62074732
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_article.py
+35
-53
35 additions, 53 deletions
tests/test_article.py
with
35 additions
and
53 deletions
tests/test_article.py
+
35
−
53
View file @
31514966
...
...
@@ -29,36 +29,29 @@ class ArticleTests(unittest.TestCase):
def
test_dummy_to_dct
(
self
):
self
.
maxDiff
=
None
expected
=
{
'
Article
'
:
{
'
aid
'
:
0
,
'
attachments
'
:
[],
'
dynamic_fields
'
:
[],
'
fields
'
:
{
'
Subject
'
:
'
Dümmy Subject
'
,
'
Body
'
:
'
Hallo Bjørn,
\n
[kt]
\n\n
-- The End
'
,
'
TimeUnit
'
:
0
,
'
MimeType
'
:
'
text/plain
'
,
'
Charset
'
:
'
UTF8
'
}}}
expected
=
{
'
Article
'
:
{
'
Subject
'
:
'
Dümmy Subject
'
,
'
Body
'
:
'
Hallo Bjørn,
\n
[kt]
\n\n
-- The End
'
,
'
TimeUnit
'
:
0
,
'
MimeType
'
:
'
text/plain
'
,
'
Charset
'
:
'
UTF8
'
}}
art
=
Article
.
_dummy
()
self
.
assertDictEqual
(
art
.
to_dct
(),
expected
)
def
test_dummy_force_notify
(
self
):
expected
=
{
'
Article
'
:
{
'
aid
'
:
0
,
'
attachments
'
:
[],
'
dynamic_fields
'
:
[],
'
fields
'
:
{
'
Subject
'
:
'
Dümmy Subject
'
,
'
Body
'
:
'
Hallo Bjørn,
\n
[kt]
\n\n
-- The End
'
,
'
TimeUnit
'
:
0
,
'
MimeType
'
:
'
text/plain
'
,
'
Charset
'
:
'
UTF8
'
,
"
ForceNotificationToUserID
"
:
[
1
,
2
]}}}
self
.
maxDiff
=
None
expected
=
{
'
Article
'
:
{
'
Subject
'
:
'
Dümmy Subject
'
,
'
Body
'
:
'
Hallo Bjørn,
\n
[kt]
\n\n
-- The End
'
,
'
TimeUnit
'
:
0
,
'
MimeType
'
:
'
text/plain
'
,
'
Charset
'
:
'
UTF8
'
,
"
ForceNotificationToUserID
"
:
[
1
,
2
]}}
art
=
Article
.
_dummy_force_notify
()
self
.
assertDictEqual
(
art
.
to_dct
(),
expected
)
def
test_dummy_static_with_article_id
(
self
):
self
.
maxDiff
=
None
art
=
Article
({
"
Subject
"
:
"
Dümmy Subject
"
,
"
Body
"
:
"
Hallo Bjørn,
\n
[kt]
\n\n
-- The End
"
,
"
ArticleID
"
:
5
,
...
...
@@ -66,21 +59,18 @@ class ArticleTests(unittest.TestCase):
"
MimeType
"
:
"
text/plain
"
,
"
Charset
"
:
"
UTF8
"
})
expected
=
{
'
Article
'
:
{
'
aid
'
:
5
,
'
attachments
'
:
[],
'
dynamic_fields
'
:
[],
'
fields
'
:
{
'
Subject
'
:
'
Dümmy Subject
'
,
'
Body
'
:
'
Hallo Bjørn,
\n
[kt]
\n\n
-- The End
'
,
'
ArticleID
'
:
5
,
'
TimeUnit
'
:
0
,
'
MimeType
'
:
'
text/plain
'
,
'
Charset
'
:
'
UTF8
'
}}}
expected
=
{
'
Article
'
:
{
'
Subject
'
:
'
Dümmy Subject
'
,
'
Body
'
:
'
Hallo Bjørn,
\n
[kt]
\n\n
-- The End
'
,
'
ArticleID
'
:
5
,
'
TimeUnit
'
:
0
,
'
MimeType
'
:
'
text/plain
'
,
'
Charset
'
:
'
UTF8
'
}}
self
.
assertDictEqual
(
art
.
to_dct
(),
expected
)
self
.
assertEqual
(
art
.
__repr__
(),
"
<ArticleID: 5>
"
)
def
test_dummy_static_with_article_id_one_att
(
self
):
self
.
maxDiff
=
None
att
=
Attachment
.
create_basic
(
"
mFyCg==
"
,
"
text/plain
"
,
"
foo.txt
"
)
art
=
Article
({
"
Subject
"
:
"
Dümmy Subject
"
,
"
Body
"
:
"
Hallo Bjørn,
\n
[kt]
\n\n
-- The End
"
,
...
...
@@ -91,16 +81,13 @@ class ArticleTests(unittest.TestCase):
art
.
attachments
=
[
att
]
expected
=
{
'
Article
'
:
{
'
aid
'
:
3
,
'
attachments
'
:
art
.
attachments
,
'
dynamic_fields
'
:
[],
'
fields
'
:
{
'
Subject
'
:
'
Dümmy Subject
'
,
'
Body
'
:
'
Hallo Bjørn,
\n
[kt]
\n\n
-- The End
'
,
'
ArticleID
'
:
3
,
'
TimeUnit
'
:
0
,
'
MimeType
'
:
'
text/plain
'
,
'
Charset
'
:
'
UTF8
'
}}}
expected
=
{
'
Article
'
:
{
'
Subject
'
:
'
Dümmy Subject
'
,
'
Body
'
:
'
Hallo Bjørn,
\n
[kt]
\n\n
-- The End
'
,
'
ArticleID
'
:
3
,
'
TimeUnit
'
:
0
,
'
MimeType
'
:
'
text/plain
'
,
'
Charset
'
:
'
UTF8
'
,
'
Attachment
'
:
art
.
attachments
}}
self
.
assertDictEqual
(
art
.
to_dct
(),
expected
)
self
.
assertEqual
(
art
.
__repr__
(),
"
<ArticleID: 3 (1 Attachment)>
"
)
...
...
@@ -118,16 +105,13 @@ class ArticleTests(unittest.TestCase):
art
.
attachments
=
[
att1
,
att2
]
expected
=
{
'
Article
'
:
{
'
aid
'
:
4
,
'
attachments
'
:
art
.
attachments
,
'
dynamic_fields
'
:
[],
'
fields
'
:
{
'
Subject
'
:
'
Dümmy Subject
'
,
'
Body
'
:
'
Hallo Bjørn,
\n
[kt]
\n\n
-- The End
'
,
'
ArticleID
'
:
4
,
'
TimeUnit
'
:
0
,
'
MimeType
'
:
'
text/plain
'
,
'
Charset
'
:
'
UTF8
'
}}}
expected
=
{
'
Article
'
:
{
'
Subject
'
:
'
Dümmy Subject
'
,
'
Body
'
:
'
Hallo Bjørn,
\n
[kt]
\n\n
-- The End
'
,
'
ArticleID
'
:
4
,
'
TimeUnit
'
:
0
,
'
MimeType
'
:
'
text/plain
'
,
'
Charset
'
:
'
UTF8
'
,
'
Attachment
'
:
art
.
attachments
}}
self
.
assertDictEqual
(
art
.
to_dct
(),
expected
)
self
.
assertEqual
(
art
.
__repr__
(),
"
<ArticleID: 4 (2 Attachments)>
"
)
...
...
@@ -301,9 +285,7 @@ class ArticleTests(unittest.TestCase):
def
test_validation
(
self
):
"""
Article validation; blacklisted fields should be removed, others should be added
"""
expected
=
{
'
Article
'
:
{
'
Subject
'
:
'
This Article only has Subject
'
,
'
Body
'
:
'
and Body and needs to be completed.
'
,
'
attachments
'
:
[],
'
dynamic_fields
'
:
[]}}
'
Body
'
:
'
and Body and needs to be completed.
'
}}
expected_validated
=
{
'
Article
'
:
{
'
Subject
'
:
'
This Article only has Subject
'
,
'
Body
'
:
'
and Body and needs to be completed.
'
,
...
...
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