QgisAlgorithmsTest4.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. """
  2. ***************************************************************************
  3. QgisAlgorithmTests2.py
  4. ---------------------
  5. Date : January 2016
  6. Copyright : (C) 2016 by Matthias Kuhn
  7. Email : matthias@opengis.ch
  8. ***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************
  16. """
  17. __author__ = 'Matthias Kuhn'
  18. __date__ = 'January 2016'
  19. __copyright__ = '(C) 2016, Matthias Kuhn'
  20. import AlgorithmsTestBase
  21. import nose2
  22. import shutil
  23. import os
  24. from qgis.core import (QgsApplication,
  25. QgsProcessingException)
  26. from qgis.analysis import (QgsNativeAlgorithms)
  27. import unittest
  28. from qgis.testing import start_app, QgisTestCase
  29. from processing.core.ProcessingConfig import ProcessingConfig
  30. from processing.modeler.ModelerUtils import ModelerUtils
  31. class TestQgisAlgorithms4(QgisTestCase, AlgorithmsTestBase.AlgorithmsTest):
  32. @classmethod
  33. def setUpClass(cls):
  34. start_app()
  35. from processing.core.Processing import Processing
  36. Processing.initialize()
  37. # change the model provider folder so that it looks in the test directory for models
  38. ProcessingConfig.setSettingValue(ModelerUtils.MODELS_FOLDER, os.path.join(os.path.dirname(__file__), 'models'))
  39. for p in QgsApplication.processingRegistry().providers():
  40. if p.id() == "model":
  41. p.refreshAlgorithms()
  42. cls.cleanup_paths = []
  43. cls.in_place_layers = {}
  44. cls.vector_layer_params = {}
  45. cls._original_models_folder = ProcessingConfig.getSetting(ModelerUtils.MODELS_FOLDER)
  46. @classmethod
  47. def tearDownClass(cls):
  48. from processing.core.Processing import Processing
  49. Processing.deinitialize()
  50. for path in cls.cleanup_paths:
  51. shutil.rmtree(path)
  52. ProcessingConfig.setSettingValue(ModelerUtils.MODELS_FOLDER, cls._original_models_folder)
  53. def test_definition_file(self):
  54. return 'qgis_algorithm_tests4.yaml'
  55. if __name__ == '__main__':
  56. nose2.main()