def test_check_file_not_ready_pull(self): """Test that checks to see if a file is not ready to pull by checking the archive response.""" response = json.dumps({ 'bytes_per_level': '(0L, 24L, 0L, 0L, 0L)', 'ctime': '1444938166', 'file': '/myemsl-dev/bundle/file.1', 'file_storage_media': 'tape', 'filesize': '24', 'message': 'File was found', 'mtime': '1444938166' }) resp_bad = json.dumps({ 'bytes_per_level': '(0L, 33L, 33L, 0L, 0L)', 'ctime': '1444938177', 'file': '/myemsl-dev/bundle/file.2', 'filesize': '33', 'message': 'File was found', 'mtime': '1444938133' }) test_cart = self.create_sample_cart() test_file = self.create_sample_file(test_cart) cart_utils = Cartutils() ready = cart_utils.check_file_ready_pull( response, test_file, test_cart ) self.assertEqual(ready, False) # now check for an error by sending a bad response ready = cart_utils.check_file_ready_pull('', test_file, test_cart) self.assertEqual(ready, -1) self.assertEqual(test_file.status, 'error') # now check for an error with storage media ready = cart_utils.check_file_ready_pull( resp_bad, test_file, test_cart ) self.assertEqual(ready, -1) self.assertEqual(test_file.status, 'error')
def test_check_file_ready_pull(self): """Test that checks to see if a file is ready to pull by checking the archive response.""" response = json.dumps({ 'bytes_per_level': '(24L, 0L, 0L, 0L, 0L)', 'ctime': '1444938166', 'file': '/myemsl-dev/bundle/file.1', 'file_storage_media': 'disk', 'filesize': '24', 'message': 'File was found', 'mtime': '1444938166' }) test_cart = self.create_sample_cart() test_file = self.create_sample_file(test_cart) cart_utils = Cartutils() ready = cart_utils.check_file_ready_pull(response, test_file, test_cart) self.assertEqual(ready['enough_space'], True) self.assertNotEqual(test_file.status, 'error')