FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-bitshares/tests/test_objectcache.py at master · bitshares/python-bitshares · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
bitshares
/
python-bitshares
Public
Notifications
You must be signed in to change notification settings
Fork
164
Star
162
Code
Issues
10
Pull requests
4
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
python-bitshares
/
tests
/
test_objectcache.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (26 loc) · 946 Bytes
Breadcrumbs
python-bitshares
/
tests
/
test_objectcache.py
Copy path
File metadata and controls
33 lines (26 loc) · 946 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
import
time
import
unittest
from
bitshares
import
BitShares
,
exceptions
from
bitshares
.
instance
import
set_shared_bitshares_instance
from
bitshares
.
blockchainobject
import
ObjectCache
class
Testcases
(
unittest
.
TestCase
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
bts
=
BitShares
(
nobroadcast
=
True
,
)
set_shared_bitshares_instance
(
self
.
bts
)
def
test_cache
(
self
):
cache
=
ObjectCache
(
default_expiration
=
1
)
self
.
assertEqual
(
str
(
cache
),
"ObjectCacheInMemory(default_expiration=1)"
)
# Data
cache
[
"foo"
]
=
"bar"
self
.
assertIn
(
"foo"
,
cache
)
self
.
assertEqual
(
cache
[
"foo"
],
"bar"
)
self
.
assertEqual
(
cache
.
get
(
"foo"
,
"New"
),
"bar"
)
# Expiration
time
.
sleep
(
2
)
self
.
assertNotIn
(
"foo"
,
cache
)
# Get
self
.
assertEqual
(
cache
.
get
(
"foo"
,
"New"
),
"New"
)
Back
|
FazBrowse Home
|
New Git URL