mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-11 15:28:27 +01:00
committed by
Ruslan Kuprieiev
parent
b3df249c9f
commit
64a4883ba1
+3
-2
@@ -263,8 +263,9 @@ class State(object):
|
||||
m = st.st_mtime
|
||||
if m > mtime:
|
||||
mtime = m
|
||||
|
||||
return (str(int(nanotime.timestamp(mtime))), size)
|
||||
# State of files handled by dvc is stored in db as TEXT.
|
||||
# We cast results to string for later comparisons with stored values.
|
||||
return str(int(nanotime.timestamp(mtime))), str(size)
|
||||
|
||||
@staticmethod
|
||||
def inode(path):
|
||||
|
||||
@@ -7,6 +7,7 @@ import shutil
|
||||
import getpass
|
||||
import platform
|
||||
import yaml
|
||||
from dvc.state import State
|
||||
from mock import patch
|
||||
|
||||
import dvc.logger as logger
|
||||
@@ -18,6 +19,7 @@ from dvc.remote.base import STATUS_OK, STATUS_NEW, STATUS_DELETED
|
||||
from dvc.utils import file_md5
|
||||
|
||||
from tests.basic_env import TestDvc
|
||||
from tests.utils import spy
|
||||
|
||||
try:
|
||||
from StringIO import StringIO
|
||||
@@ -684,3 +686,16 @@ class TestRecursiveSyncOperations(TestDataCloudBase):
|
||||
self._test_recursive_fetch(data_md5, data_sub_md5)
|
||||
|
||||
self._test_recursive_pull()
|
||||
|
||||
|
||||
class TestCheckSumRecalculation(TestDvc):
|
||||
|
||||
def test(self):
|
||||
test_collect = spy(State._collect)
|
||||
with patch.object(State, '_collect', test_collect):
|
||||
url = get_local_url()
|
||||
main(['remote', 'add', '-d', TEST_REMOTE, url])
|
||||
main(['add', self.FOO])
|
||||
main(['push'])
|
||||
main(['run', '-d', self.FOO, 'echo foo'])
|
||||
self.assertEqual(test_collect.mock.call_count, 1)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
from dvc.state import State
|
||||
from tests.basic_env import TestDvc
|
||||
|
||||
|
||||
class TestMtimeAndSizeReturnType(TestDvc):
|
||||
def test(self):
|
||||
file_time, file_size = State.mtime_and_size(self.DATA)
|
||||
dir_time, dir_size = State.mtime_and_size(self.DATA_DIR)
|
||||
|
||||
self.assertIs(type(file_time), str)
|
||||
self.assertIs(type(file_size), str)
|
||||
self.assertIs(type(dir_time), str)
|
||||
self.assertIs(type(dir_size), str)
|
||||
@@ -0,0 +1,12 @@
|
||||
from mock import MagicMock
|
||||
|
||||
|
||||
def spy(method_to_decorate):
|
||||
mock = MagicMock()
|
||||
|
||||
def wrapper(self, *args, **kwargs):
|
||||
mock(*args, **kwargs)
|
||||
return method_to_decorate(self, *args, **kwargs)
|
||||
|
||||
wrapper.mock = mock
|
||||
return wrapper
|
||||
|
||||
Reference in New Issue
Block a user