Beispiel #1
0
class TestSizeOnlySync(unittest.TestCase):
    def setUp(self):
        self.sync_strategy = SizeOnlySync()

    def test_compare_size_only(self):
        """
        Confirm that files are synced when size differs.
        """
        time_src = datetime.datetime.now()
        time_dst = time_src + datetime.timedelta(days=1)

        src_file = FileStat(src='', dest='',
                            compare_key='test.py', size=11,
                            last_update=time_src, src_type='local',
                            dest_type='s3', operation_name='upload')

        dst_file = FileStat(src='', dest='',
                            compare_key='test.py', size=10,
                            last_update=time_dst, src_type='s3',
                            dest_type='local', operation_name='')

        should_sync = self.sync_strategy.determine_should_sync(
            src_file, dst_file)
        self.assertTrue(should_sync)

    def test_compare_size_only_different_update_times(self):
        """
        Confirm that files with the same size but different update times
        are not synced.
        """
        time_src = datetime.datetime.now()
        time_dst = time_src + datetime.timedelta(days=1)

        src_file = FileStat(src='', dest='',
                            compare_key='test.py', size=10,
                            last_update=time_src, src_type='local',
                            dest_type='s3', operation_name='upload')

        dst_file = FileStat(src='', dest='',
                            compare_key='test.py', size=10,
                            last_update=time_dst, src_type='s3',
                            dest_type='local', operation_name='')

        should_sync = self.sync_strategy.determine_should_sync(
            src_file, dst_file)
        self.assertFalse(should_sync)
Beispiel #2
0
 def setUp(self):
     self.sync_strategy = SizeOnlySync()
Beispiel #3
0
class TestSizeOnlySync(unittest.TestCase):
    def setUp(self):
        self.sync_strategy = SizeOnlySync()

    def test_compare_size_only(self):
        """
        Confirm that files are synced when size differs.
        """
        time_src = datetime.datetime.now()
        time_dst = time_src + datetime.timedelta(days=1)

        src_file = FileStat(src='',
                            dest='',
                            compare_key='test.py',
                            size=11,
                            last_update=time_src,
                            src_type='local',
                            dest_type='s3',
                            operation_name='upload')

        dst_file = FileStat(src='',
                            dest='',
                            compare_key='test.py',
                            size=10,
                            last_update=time_dst,
                            src_type='s3',
                            dest_type='local',
                            operation_name='')

        should_sync = self.sync_strategy.determine_should_sync(
            src_file, dst_file)
        self.assertTrue(should_sync)

    def test_compare_size_only_different_update_times(self):
        """
        Confirm that files with the same size but different update times
        are not synced.
        """
        time_src = datetime.datetime.now()
        time_dst = time_src + datetime.timedelta(days=1)

        src_file = FileStat(src='',
                            dest='',
                            compare_key='test.py',
                            size=10,
                            last_update=time_src,
                            src_type='local',
                            dest_type='s3',
                            operation_name='upload')

        dst_file = FileStat(src='',
                            dest='',
                            compare_key='test.py',
                            size=10,
                            last_update=time_dst,
                            src_type='s3',
                            dest_type='local',
                            operation_name='')

        should_sync = self.sync_strategy.determine_should_sync(
            src_file, dst_file)
        self.assertFalse(should_sync)
Beispiel #4
0
 def setUp(self):
     self.sync_strategy = SizeOnlySync()