Exemple #1
0
 def test_gluster_check_metadata(self):
     mock_check_metadata = Mock()
     with patch('gluster.swift.common.constraints.__check_metadata',
                mock_check_metadata):
         req = Mock()
         req.headers = []
         cnt.gluster_check_metadata(req, 'object')
         self.assertTrue(1, mock_check_metadata.call_count)
         cnt.gluster_check_metadata(req, 'object', POST=False)
         self.assertTrue(1, mock_check_metadata.call_count)
         req.headers = ['x-some-header']
         self.assertEqual(
             cnt.gluster_check_metadata(req, 'object', POST=False), None)
         #TODO: Although we now support x-delete-at and x-delete-after,
         #retained this test case as we may add some other header to
         #unsupported list in future
         raise SkipTest
         req.headers = ['x-delete-at', 'x-some-header']
         self.assertNotEqual(
             cnt.gluster_check_metadata(req, 'object', POST=False), None)
         req.headers = ['x-delete-after', 'x-some-header']
         self.assertNotEqual(
             cnt.gluster_check_metadata(req, 'object', POST=False), None)
         req.headers = ['x-delete-at', 'x-delete-after', 'x-some-header']
         self.assertNotEqual(
             cnt.gluster_check_metadata(req, 'object', POST=False), None)
 def test_gluster_check_metadata(self):
     mock_check_metadata = Mock()
     with patch('gluster.swift.common.constraints.__check_metadata',
                mock_check_metadata):
         req = Mock()
         req.headers = []
         cnt.gluster_check_metadata(req, 'object')
         self.assertTrue(1, mock_check_metadata.call_count)
         cnt.gluster_check_metadata(req, 'object', POST=False)
         self.assertTrue(1, mock_check_metadata.call_count)
         req.headers = ['x-some-header']
         self.assertEqual(cnt.gluster_check_metadata(req, 'object', POST=False), None)
         req.headers = ['x-delete-at', 'x-some-header']
         self.assertNotEqual(cnt.gluster_check_metadata(req, 'object', POST=False), None)
         req.headers = ['x-delete-after', 'x-some-header']
         self.assertNotEqual(cnt.gluster_check_metadata(req, 'object', POST=False), None)
         req.headers = ['x-delete-at', 'x-delete-after', 'x-some-header']
         self.assertNotEqual(cnt.gluster_check_metadata(req, 'object', POST=False), None)
 def test_gluster_check_metadata(self):
     mock_check_metadata = Mock()
     with patch('gluster.swift.common.constraints.__check_metadata',
                mock_check_metadata):
         req = Mock()
         req.headers = []
         cnt.gluster_check_metadata(req, 'object')
         self.assertTrue(1, mock_check_metadata.call_count)
         cnt.gluster_check_metadata(req, 'object', POST=False)
         self.assertTrue(1, mock_check_metadata.call_count)
         req.headers = ['x-some-header']
         self.assertEqual(cnt.gluster_check_metadata(req, 'object', POST=False), None)
         #TODO: Although we now support x-delete-at and x-delete-after,
         #retained this test case as we may add some other header to
         #unsupported list in future
         raise SkipTest
         req.headers = ['x-delete-at', 'x-some-header']
         self.assertNotEqual(cnt.gluster_check_metadata(req, 'object', POST=False), None)
         req.headers = ['x-delete-after', 'x-some-header']
         self.assertNotEqual(cnt.gluster_check_metadata(req, 'object', POST=False), None)
         req.headers = ['x-delete-at', 'x-delete-after', 'x-some-header']
         self.assertNotEqual(cnt.gluster_check_metadata(req, 'object', POST=False), None)