Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
UCC
uccportal
Commits
8bf82864
Commit
8bf82864
authored
Mar 03, 2019
by
frekk
Browse files
add testing for cokelog stuff
parent
8a064a04
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/squarepay/tests.py
View file @
8bf82864
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.conf
import
settings
from
datetime
import
datetime
# Create your tests here.
from
.cokelog
import
CokeLog
class
ParseCokeLog
(
TestCase
):
def
test_parse_cokelog
(
self
):
fn
=
getattr
(
settings
,
'COKELOG_PATH'
,
None
)
if
fn
is
None
:
return
cokelog
=
CokeLog
()
self
.
assertFalse
(
cokelog
.
is_loaded
())
cokelog
.
open
()
self
.
assertTrue
(
cokelog
.
is_loaded
())
self
.
assertIsInstance
(
cokelog
.
dispenses
,
dict
)
for
key
,
val
in
cokelog
.
dispenses
.
items
():
self
.
assertIsInstance
(
val
,
(
list
,
tuple
))
for
record
in
val
:
self
.
assertIsInstance
(
record
,
dict
)
self
.
assertTrue
(
'by'
in
record
)
self
.
assertTrue
(
'item'
in
record
)
self
.
assertIsInstance
(
record
[
'date'
],
datetime
)
n
=
len
(
cokelog
.
dispenses
)
cokelog
.
reload
()
self
.
assertTrue
(
n
==
len
(
cokelog
.
dispenses
))
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