def test_check_space_requirements(self): """Test that there is enough space on the volume for the file.""" test_cart = self.create_sample_cart() test_file = self.create_sample_file(test_cart) cart_utils = Cartutils() rtn = cart_utils.check_space_requirements(test_file, test_cart, 10, False) self.assertEqual(rtn, True) self.assertNotEqual(test_file.status, 'error') # now check for an error by sending a way to large size needed number rtn = cart_utils.check_space_requirements(test_file, test_cart, 9999999999999999999999, True) self.assertEqual(rtn, False) self.assertEqual(test_file.status, 'error')
def test_check_space_bad_path(self, mock_disk_usage): """Test that the error when a bad path.""" test_cart = self.create_sample_cart() test_file = self.create_sample_file(test_cart) cart_utils = Cartutils() mock_disk_usage.side_effect = psutil.Error(mock.Mock()) rtn = cart_utils.check_space_requirements(test_file, test_cart, 10, False) self.assertEqual(rtn, False) self.assertEqual(test_file.status, 'error')
def test_check_space_disabled(self): """Test that the error when a bad path.""" test_cart = self.create_sample_cart() test_file = self.create_sample_file(test_cart) os.environ['LRU_PURGE'] = 'off' cart_utils = Cartutils() rtn = cart_utils.check_space_requirements( test_file, test_cart, 10, False ) self.assertEqual(rtn, True) del os.environ['LRU_PURGE']