File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1
1
import datetime
2
2
import os
3
3
import unittest
4
+ import tempfile
5
+ import odml .terminology
6
+ from hashlib import md5
4
7
try :
5
8
from urllib .request import pathname2url
6
9
except ImportError :
@@ -109,6 +112,34 @@ def test_get_terminology_equivalent(self):
109
112
doc .repository = None
110
113
self .assertIsNone (doc .get_terminology_equivalent ())
111
114
115
+ def test_terminology_refresh (self ):
116
+
117
+ cache_dir = os .path .join (tempfile .gettempdir (), "odml.cache" )
118
+ url = "https://terminologies.g-node.org/v1.1/terminologies.xml"
119
+ term_doc = odml .terminology .load (url )
120
+
121
+ terms = []
122
+ for sec in term_doc .sections :
123
+ terms += ['.' .join ([md5 (sec .include .encode ()).hexdigest (), os .path .basename (sec .include )])]
124
+
125
+ before = datetime .datetime .now ()
126
+
127
+ for loaded_file in os .listdir (cache_dir ):
128
+ for term in terms :
129
+ if term in loaded_file :
130
+ assert datetime .datetime .fromtimestamp (
131
+ os .path .getmtime (os .path .join (cache_dir , loaded_file ))) < before
132
+
133
+ odml .terminology .refresh (url )
134
+
135
+ for replaced_file in os .listdir (cache_dir ):
136
+ for term in terms :
137
+ if term in replaced_file :
138
+ assert datetime .datetime .fromtimestamp (
139
+ os .path .getmtime (os .path .join (cache_dir , replaced_file ))) > before
140
+
141
+
142
+
112
143
def test_append (self ):
113
144
doc = Document ()
114
145
self .assertListEqual (doc .sections , [])
You can’t perform that action at this time.
0 commit comments