Rewrite needs_parsing-test
it now copies the testlog to a tmpfile first and adds a line to check if Cache.needs_parsing is working correctly
This commit is contained in:
parent
ff22ed86f2
commit
0f0386f14a
|
@ -1,6 +1,9 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
import shutil
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tsstats.cache import Cache, CachedLog, _calculate_hash
|
from tsstats.cache import Cache, CachedLog, _calculate_hash
|
||||||
|
@ -48,10 +51,17 @@ def test_cache_read_write(cache):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_cache_needs_parsing(cache):
|
def test_cache_needs_parsing(cache, tmpdir):
|
||||||
cache[testlog_path] = []
|
tmplog_path = str(tmpdir.mkdir('cache').join('test.log'))
|
||||||
assert not cache.needs_parsing(testlog_path)
|
# copy logfile to temporary location
|
||||||
assert cache.needs_parsing(testlog_path + '.nl')
|
shutil.copy(testlog_path, tmplog_path)
|
||||||
|
|
||||||
|
assert cache.needs_parsing(tmplog_path)
|
||||||
|
cache[tmplog_path] = []
|
||||||
|
assert not cache.needs_parsing(tmplog_path)
|
||||||
|
with open(tmplog_path, 'a') as f:
|
||||||
|
f.writelines(['content'])
|
||||||
|
assert cache.needs_parsing(tmplog_path)
|
||||||
|
|
||||||
|
|
||||||
# INTEGRATION
|
# INTEGRATION
|
||||||
|
|
Loading…
Reference in New Issue