Exemplo n.º 1
0
    def test_ship_only_ships_if_only_slip_found(self, listdir, copy_data,
                                                config_prop, packing_slip,
                                                exists, socket, generate_mock):
        def mock_props(value):
            if value == 'servers':
                return [{
                    'machineName': '0-host',
                    'username': '******',
                    'password': '******',
                    'port': 0
                }]

            return 'whatever'

        config_prop.side_effect = mock_props

        engine.ship_data()

        expected_report = {
            'hostname': 'test.host',
            'total_pallets': 0,
            'pallets': [],
            'num_success_pallets': 0,
            'server_reports': []
        }

        #: we don't care about total_time since it can vary between test runs
        assert expected_report.items() <= generate_mock.call_args[0][0].items()
        copy_data.assert_not_called()
        packing_slip.assert_called_once()
Exemplo n.º 2
0
    def test_post_process_if_not_success(self, listdir, copy_data, packing_slip, exists, generate_mock):
        slip = {'success': False, 'requires_processing': True}
        pallet = Mock(slip=slip, total_processing_time=3)
        pallet.ship.return_value = None
        pallet.post_copy_process.return_value = None
        pallet.copy_data = []
        packing_slip.return_value = [pallet]

        engine.ship_data()

        pallet.ship.assert_not_called()
        pallet.post_copy_process.assert_not_called()
Exemplo n.º 3
0
    def test_ship_exits_if_no_files_or_slip(self, listdir):
        shipped = engine.ship_data()

        self.assertFalse(shipped)