Example #1
0
    def test_move_file(self, mock_rename, mock_makedirs):
        fm = FileMover(self.dummy_options)

        with self.assertRaises(Exception):
            fm._move_file("filename", "dummy")

        fm._get_acc_cont_obj = mock.Mock()
        info = {'account': 'account',
                'container': 'container',
                'object': 'object'}
        fm._get_acc_cont_obj.return_value = info

        fm._move_file("node/objects/0/obj.data", "objects")

        mock_rename.assert_called_with('node/objects/0/obj.data',
                                       'node/objects/61/obj.data')
        mock_makedirs.assert_called_with('node/objects/61')
Example #2
0
    def test_filemover_start(self, mock_walk):
        # Simulate Swift storage node files
        mock_walk.return_value = [('accounts',
                                   '_dirs',
                                   ['account.db']),
                                  ('containers',
                                   '_dirs',
                                   ['container.db']),
                                  ('objects',
                                   '_dirs',
                                   ['object.data']),
                                  ]

        fm = FileMover(self.dummy_options)

        fm._move_file = mock.Mock()
        fm.start()
        fm._move_file.assert_any_call('accounts/account.db',
                                      'accounts')
        fm._move_file.assert_any_call('containers/container.db',
                                      'containers')
        fm._move_file.assert_any_call('objects/object.data',
                                      'objects')