Example #1
0
 def test_nested_folder_str(self):
     grand = LocalFolder('grand')
     parent = LocalFolder('parent')
     parent.add_child(LocalFile('setup.py'))
     parent.add_child(LocalFile('requirements.txt'))
     otherparent = LocalFolder('otherparent')
     grand.add_child(parent)
     grand.add_child(otherparent)
     self.assertEqual(('folder:grand ['
                        'folder:parent [file:setup.py, file:requirements.txt], '
                        'folder:otherparent []]'), str(grand))
Example #2
0
 def test_total_items(self, mock_path_data, mock_os):
     counter = LocalOnlyCounter(bytes_per_chunk=100)
     self.assertEqual(0, counter.total_items())
     f = LocalFile('fakefile.txt')
     f.size = 0
     counter.visit_file(f, None)
     self.assertEqual(1, counter.total_items())
     f = LocalFile('fakefile2.txt')
     f.size = 200
     counter.visit_file(f, None)
     self.assertEqual(3, counter.total_items())
 def test_count_chunks_values(self, mock_path_data, mock_os):
     values = [
         # file_size, bytes_per_chunk, expected
         (200, 10, 20),
         (200, 150, 2),
         (3, 150, 1),
         (0, 10, 1),  # Empty files must send 1 empty chunk to DukeDS
     ]
     f = LocalFile('fakefile.txt')
     for file_size, bytes_per_chunk, expected in values:
         f.size = file_size
         self.assertEqual(expected, f.count_chunks(bytes_per_chunk))
Example #4
0
 def test_count_chunks_values(self, mock_path_data, mock_os):
     values = [
         # file_size, bytes_per_chunk, expected
         (200, 10, 20),
         (200, 150, 2),
         (3, 150, 1),
         (0, 10, 1),  # Empty files must send 1 empty chunk to DukeDS
     ]
     f = LocalFile('fakefile.txt')
     for file_size, bytes_per_chunk, expected in values:
         f.size = file_size
         self.assertEqual(expected, f.count_chunks(bytes_per_chunk))
Example #5
0
 def test_total_items(self, mock_path_data, mock_os):
     counter = LocalOnlyCounter(bytes_per_chunk=100)
     self.assertEqual(0, counter.total_items())
     f = LocalFile('fakefile.txt')
     f.size = 0
     counter.visit_file(f, None)
     self.assertEqual(1, counter.total_items())
     f = LocalFile('fakefile2.txt')
     f.size = 200
     counter.visit_file(f, None)
     self.assertEqual(3, counter.total_items())
Example #6
0
 def test_folder_two_children_str(self):
     folder = LocalFolder('stuff')
     folder.add_child(LocalFile('setup.py'))
     folder.add_child(LocalFile('requirements.txt'))
     self.assertEqual('folder:stuff [file:setup.py, file:requirements.txt]', str(folder))
Example #7
0
 def test_folder_one_child_str(self):
     folder = LocalFolder('stuff')
     folder.add_child(LocalFile('setup.py'))
     self.assertEqual('folder:stuff [file:setup.py]', str(folder))
Example #8
0
 def test_file_str(self):
     f = LocalFile('setup.py')
     self.assertEqual('file:setup.py', str(f))