示例#1
0
    def test_successful_pallet(self):
        pallet = Pallet()
        pallet.add_crates(
            ['fc1', 'fc2', 'fc3'], {
                'source_workspace': 'Z:\\a\\path\\to\\database.sde',
                'destination_workspace': 'Z:\\a\\path\\to\\database.gdb'
            })
        pallet.success = (True, None)
        pallet.name = 'name'
        pallet._crates[0].result = (Crate.CREATED, None)
        pallet._crates[1].result = (Crate.UPDATED, None)
        pallet._crates[2].result = (Crate.NO_CHANGES, None)
        report = pallet.get_report()

        self.assertEqual(report['name'], 'name')
        self.assertEqual(report['success'], True)
        self.assertEqual(len(report['crates']), 2)
        self.assertEqual(report['crates'][0]['result'], Crate.CREATED, None)
        self.assertEqual(report['crates'][0]['name'], 'fc1')
示例#2
0
    def test_failed_pallet(self):
        pallet = Pallet()
        pallet.add_crates(
            ['fc4', 'fc5', 'fc6'], {
                'source_workspace': 'Z:\\a\\path\\to\\database.sde',
                'destination_workspace': 'Z:\\a\\path\\to\\database.gdb'
            })
        pallet.success = (False, 'Failed message')
        pallet._crates[0].result = (Crate.UPDATED, None)
        pallet._crates[1].result = (Crate.INVALID_DATA, 'Invalid data message')
        pallet._crates[2].result = (Crate.UNHANDLED_EXCEPTION, None)

        report = pallet.get_report()

        self.assertEqual(report['success'], False)
        self.assertEqual(report['message'], 'Failed message')
        self.assertEqual(len(report['crates']), 3)
        self.assertEqual(report['crates'][1]['result'], Crate.INVALID_DATA)
        self.assertEqual(report['crates'][1]['crate_message'],
                         'Invalid data message')