Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
493148f7
Commit
493148f7
authored
Dec 24, 2016
by
Krophil
Browse files
new tests for operations
parent
f7b4258f
Pipeline
#631
passed with stage
in 2 minutes and 42 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
accounting/tests.py
View file @
493148f7
...
...
@@ -6,7 +6,7 @@ from django.conf import settings
from
core.models
import
User
from
counter.models
import
Counter
from
accounting.models
import
GeneralJournal
,
Operation
,
AccountingType
from
accounting.models
import
GeneralJournal
,
Operation
,
AccountingType
,
SimplifiedAccountingType
class
RefoundAccountTest
(
TestCase
):
...
...
@@ -75,7 +75,6 @@ class OperationTest(TestCase):
def
test_new_operation
(
self
):
self
.
client
.
login
(
username
=
'comptable'
,
password
=
'plop'
)
at
=
AccountingType
.
objects
.
filter
(
code
=
'604'
).
first
()
at
.
save
()
response
=
self
.
client
.
post
(
reverse
(
'accounting:op_new'
,
args
=
[
self
.
journal
.
id
]),
{
'amount'
:
30
,
...
...
@@ -95,11 +94,34 @@ class OperationTest(TestCase):
})
self
.
assertFalse
(
response
.
status_code
==
403
)
self
.
assertTrue
(
self
.
journal
.
operations
.
filter
(
target_label
=
"Le fantome de la nuit"
).
exists
())
response_get
=
self
.
client
.
get
(
reverse
(
"accounting:journal_details"
,
args
=
[
self
.
journal
.
id
]))
self
.
assertTrue
(
'<td>Le fantome de la nuit</td>'
in
str
(
response_get
.
content
))
def
test_bad_new_operation
(
self
):
self
.
client
.
login
(
username
=
'comptable'
,
password
=
'plop'
)
at
=
AccountingType
.
objects
.
filter
(
code
=
'604'
).
first
()
response
=
self
.
client
.
post
(
reverse
(
'accounting:op_new'
,
args
=
[
self
.
journal
.
id
]),
{
'amount'
:
30
,
'remark'
:
"Un gros test"
,
'journal'
:
self
.
journal
.
id
,
'target_type'
:
'OTHER'
,
'target_id'
:
''
,
'target_label'
:
"Le fantome de la nuit"
,
'date'
:
'04/12/2020'
,
'mode'
:
'CASH'
,
'cheque_number'
:
''
,
'invoice'
:
''
,
'simpleaccounting_type'
:
''
,
'accounting_type'
:
''
,
'label'
:
''
,
'done'
:
False
,
})
self
.
assertTrue
(
'Vous devez fournir soit un type comptable simplifi
\\
xc3
\\
xa9 ou un type comptable standard'
in
str
(
response
.
content
))
def
test_new_operation_not_authorized
(
self
):
self
.
client
.
login
(
username
=
'skia'
,
password
=
'plop'
)
at
=
AccountingType
.
objects
.
filter
(
code
=
'604'
).
first
()
at
.
save
()
response
=
self
.
client
.
post
(
reverse
(
'accounting:op_new'
,
args
=
[
self
.
journal
.
id
]),
{
'amount'
:
30
,
...
...
@@ -107,7 +129,7 @@ class OperationTest(TestCase):
'journal'
:
self
.
journal
.
id
,
'target_type'
:
'OTHER'
,
'target_id'
:
''
,
'target_label'
:
"Le fantome d
e la nuit
"
,
'target_label'
:
"Le fantome d
u jour
"
,
'date'
:
'04/12/2020'
,
'mode'
:
'CASH'
,
'cheque_number'
:
''
,
...
...
@@ -117,4 +139,31 @@ class OperationTest(TestCase):
'label'
:
''
,
'done'
:
False
,
})
self
.
assertTrue
(
response
.
status_code
==
403
)
\ No newline at end of file
self
.
assertTrue
(
response
.
status_code
==
403
)
self
.
assertFalse
(
self
.
journal
.
operations
.
filter
(
target_label
=
"Le fantome du jour"
).
exists
())
def
test__operation_simple_accounting
(
self
):
self
.
client
.
login
(
username
=
'comptable'
,
password
=
'plop'
)
sat
=
SimplifiedAccountingType
.
objects
.
all
().
first
()
response
=
self
.
client
.
post
(
reverse
(
'accounting:op_new'
,
args
=
[
self
.
journal
.
id
]),
{
'amount'
:
23
,
'remark'
:
"Un gros test"
,
'journal'
:
self
.
journal
.
id
,
'target_type'
:
'OTHER'
,
'target_id'
:
''
,
'target_label'
:
"Le fantome de l'aurore"
,
'date'
:
'04/12/2020'
,
'mode'
:
'CASH'
,
'cheque_number'
:
''
,
'invoice'
:
''
,
'simpleaccounting_type'
:
sat
.
id
,
'accounting_type'
:
''
,
'label'
:
''
,
'done'
:
False
,
})
self
.
assertFalse
(
response
.
status_code
==
403
)
self
.
assertTrue
(
self
.
journal
.
operations
.
filter
(
amount
=
23
).
exists
())
response_get
=
self
.
client
.
get
(
reverse
(
"accounting:journal_details"
,
args
=
[
self
.
journal
.
id
]))
self
.
assertTrue
(
"<td>Le fantome de l'aurore</td>"
in
str
(
response_get
.
content
))
self
.
assertTrue
(
self
.
journal
.
operations
.
filter
(
amount
=
23
).
values
(
'accounting_type'
).
first
()[
'accounting_type'
]
==
AccountingType
.
objects
.
filter
(
code
=
6
).
values
(
'id'
).
first
()[
'id'
])
\ No newline at end of file
Write
Preview
Supports
Markdown
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