コード例 #1
0
    def test_copy_data_turns_off_and_on_services(self, copytree_mock,
                                                 rmtree_mock, move,
                                                 exists_mock, compact_mock,
                                                 describe_mock,
                                                 lightswitch_mock):
        describe_mock.side_effect = describe_side_effect
        exists_mock.return_value = True
        lightswitch_mock().ensure.return_value = (True, [])
        three = 'C:\\MapData\\three.gdb'
        two = 'C:\\MapData\\two.gdb'

        pallet_one = Pallet()
        pallet_one.copy_data = ['C:\\MapData\\one.gdb', two]
        pallet_one.arcgis_services = [('Pallet', 'MapServer')]
        pallet_one.requires_processing = Mock(return_value=True)

        pallet_two = Pallet()
        pallet_two.copy_data = ['C:\\MapData\\one.gdb', three]
        pallet_two.arcgis_services = [('Pallet', 'MapServer')]
        pallet_two.requires_processing = Mock(return_value=True)

        pallet_three = Pallet()
        pallet_three.copy_data = ['C:\\MapData\\four', three]

        lift.copy_data([pallet_one, pallet_two, pallet_three],
                       [pallet_one, pallet_two, pallet_three],
                       ['dest1', 'dest2'])

        self.assertEqual(copytree_mock.call_count, 6)
        self.assertEqual(rmtree_mock.call_count, 6)
        self.assertEqual(compact_mock.call_count, 3)
        lightswitch_mock().ensure.assert_has_calls([
            call('off', set([('Pallet', 'MapServer')])),
            call('on', set([('Pallet', 'MapServer')]))
        ])
コード例 #2
0
    def test_copy_data_scrub_hash_field(self):
        copy_data_fgdb_name = 'CopyData.gdb'
        copied_data = path.join(current_folder, copy_data_fgdb_name)

        def cleanup():
            print('cleaning up')
            if arcpy.Exists(copied_data):
                arcpy.Delete_management(copied_data)

        cleanup()

        pallet = Pallet()
        pallet.copy_data = [
            path.join(current_folder, 'data', copy_data_fgdb_name)
        ]
        pallet.requires_processing = Mock(return_value=True)

        lift.copy_data([pallet], [pallet], [current_folder])

        feature_class_fields = [
            field.name for field in arcpy.Describe(
                path.join(copied_data, 'DNROilGasWells_adds')).fields
        ]
        table_fields = [
            field.name for field in arcpy.Describe(
                path.join(copied_data, 'Providers_adds')).fields
        ]

        self.assertNotIn(core.hash_field, feature_class_fields)
        self.assertNotIn(core.hash_field, table_fields)

        cleanup()
コード例 #3
0
    def test_copy_data(self, copytree_mock, rmtree_mock, move, exists_mock,
                       compact_mock, describe_mock):
        describe_mock.side_effect = describe_side_effect
        exists_mock.return_value = True
        three = 'C:\\MapData\\three.gdb'
        two = 'C:\\MapData\\two.gdb'

        pallet_one = Pallet()
        pallet_one.copy_data = ['C:\\MapData\\one.gdb', two]
        pallet_one.requires_processing = Mock(return_value=True)

        pallet_two = Pallet()
        pallet_two.copy_data = ['C:\\MapData\\one.gdb', three]
        pallet_two.requires_processing = Mock(return_value=True)

        pallet_three = Pallet()
        pallet_three.copy_data = ['C:\\MapData\\four', three]

        lift.copy_data([pallet_one, pallet_two, pallet_three],
                       [pallet_one, pallet_two, pallet_three],
                       ['dest1', 'dest2'])

        self.assertEqual(copytree_mock.call_count, 6)
        self.assertEqual(rmtree_mock.call_count, 6)
        self.assertEqual(compact_mock.call_count, 3)
コード例 #4
0
ファイル: test_lift.py プロジェクト: agrc/forklift
    def test_copy_data_turns_off_and_on_services(self, copytree_mock, rmtree_mock, move, exists_mock, compact_mock,
                                                 describe_mock, lightswitch_mock):
        describe_mock.side_effect = describe_side_effect
        exists_mock.return_value = True
        lightswitch_mock().ensure.return_value = (True, [])
        three = 'C:\\MapData\\three.gdb'
        two = 'C:\\MapData\\two.gdb'

        pallet_one = Pallet()
        pallet_one.copy_data = ['C:\\MapData\\one.gdb', two]
        pallet_one.arcgis_services = [('Pallet', 'MapServer')]
        pallet_one.requires_processing = Mock(return_value=True)

        pallet_two = Pallet()
        pallet_two.copy_data = ['C:\\MapData\\one.gdb', three]
        pallet_two.arcgis_services = [('Pallet', 'MapServer')]
        pallet_two.requires_processing = Mock(return_value=True)

        pallet_three = Pallet()
        pallet_three.copy_data = ['C:\\MapData\\four', three]

        lift.copy_data([pallet_one, pallet_two, pallet_three], [pallet_one, pallet_two, pallet_three], ['dest1', 'dest2'])

        self.assertEqual(copytree_mock.call_count, 6)
        self.assertEqual(rmtree_mock.call_count, 6)
        self.assertEqual(compact_mock.call_count, 3)
        lightswitch_mock().ensure.assert_has_calls([call('off', set([('Pallet', 'MapServer')])), call('on', set([('Pallet', 'MapServer')]))])
コード例 #5
0
ファイル: test_lift.py プロジェクト: agrc/forklift
    def test_copy_data_error(self, copytree_mock, rmtree_mock, move, compact_mock, describe_mock):
        describe_mock.side_effect = describe_side_effect
        error_message = 'there was an error'
        copytree_mock.side_effect = Exception(error_message)

        pallet = Pallet()
        pallet.copy_data = ['C:\\MapData\\one.gdb']
        pallet.requires_processing = Mock(return_value=True)

        lift.copy_data([pallet], [pallet], ['hello'])

        self.assertEqual(pallet.success, (False, error_message))
コード例 #6
0
    def test_copy_data_error(self, copytree_mock, rmtree_mock, move,
                             compact_mock, describe_mock):
        describe_mock.side_effect = describe_side_effect
        error_message = 'there was an error'
        copytree_mock.side_effect = Exception(error_message)

        pallet = Pallet()
        pallet.copy_data = ['C:\\MapData\\one.gdb']
        pallet.requires_processing = Mock(return_value=True)

        lift.copy_data([pallet], [pallet], ['hello'])

        self.assertEqual(pallet.success, (False, error_message))
コード例 #7
0
    def test_copy_data_error(self, copytree_mock, rmtree_mock, move, compact_mock, describe_mock, listdir_mock):
        describe_mock.side_effect = describe_side_effect
        error_message = 'there was an error'
        copytree_mock.side_effect = Exception(error_message)

        pallet = Pallet()
        pallet.copy_data = ['C:\\MapData\\one.gdb']
        pallet.requires_processing = Mock(return_value=True)

        success, failed = lift.copy_data('from_location', 'to_location', engine.packing_slip_file)

        self.assertTrue(failed['testfile'].startswith(error_message))
コード例 #8
0
ファイル: test_lift.py プロジェクト: agrc/forklift
    def test_copy_data(self, copytree_mock, rmtree_mock, move, exists_mock, compact_mock, describe_mock):
        describe_mock.side_effect = describe_side_effect
        exists_mock.return_value = True
        three = 'C:\\MapData\\three.gdb'
        two = 'C:\\MapData\\two.gdb'

        pallet_one = Pallet()
        pallet_one.copy_data = ['C:\\MapData\\one.gdb', two]
        pallet_one.requires_processing = Mock(return_value=True)

        pallet_two = Pallet()
        pallet_two.copy_data = ['C:\\MapData\\one.gdb', three]
        pallet_two.requires_processing = Mock(return_value=True)

        pallet_three = Pallet()
        pallet_three.copy_data = ['C:\\MapData\\four', three]

        lift.copy_data([pallet_one, pallet_two, pallet_three], [pallet_one, pallet_two, pallet_three], ['dest1', 'dest2'])

        self.assertEqual(copytree_mock.call_count, 6)
        self.assertEqual(rmtree_mock.call_count, 6)
        self.assertEqual(compact_mock.call_count, 3)
コード例 #9
0
    def test_copy_data_scrub_hash_field(self):
        copy_data_fgdb_name = 'CopyData.gdb'
        from_folder = path.join(current_folder, 'data', 'copy_data')
        to_folder = path.join(current_folder, 'data', 'pickup')
        copied_data = path.join(to_folder, copy_data_fgdb_name)

        def cleanup():
            print('cleaning up')
            if arcpy.Exists(to_folder):
                arcpy.Delete_management(to_folder)

        cleanup()

        lift.copy_data(from_folder, to_folder, engine.packing_slip_file)
        lift.gift_wrap(to_folder)

        feature_class_fields = [field.name for field in arcpy.Describe(path.join(copied_data, 'DNROilGasWells_adds')).fields]
        table_fields = [field.name for field in arcpy.Describe(path.join(copied_data, 'Providers_adds')).fields]

        self.assertNotIn(core.hash_field, feature_class_fields)
        self.assertNotIn(core.hash_field, table_fields)

        cleanup()