test_scope.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright 2023 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. import pytest
  12. from src.taipy.config.common.scope import Scope
  13. def test_scope():
  14. # Test __ge__ method
  15. assert Scope.GLOBAL >= Scope.GLOBAL
  16. assert Scope.GLOBAL >= Scope.CYCLE
  17. assert Scope.CYCLE >= Scope.CYCLE
  18. assert Scope.GLOBAL >= Scope.SCENARIO
  19. assert Scope.CYCLE >= Scope.SCENARIO
  20. assert Scope.SCENARIO >= Scope.SCENARIO
  21. with pytest.raises(TypeError):
  22. assert Scope.SCENARIO >= "testing string"
  23. # Test __gt__ method
  24. assert Scope.GLOBAL > Scope.CYCLE
  25. assert Scope.GLOBAL > Scope.SCENARIO
  26. assert Scope.CYCLE > Scope.SCENARIO
  27. with pytest.raises(TypeError):
  28. assert Scope.SCENARIO > "testing string"
  29. # Test __le__ method
  30. assert Scope.GLOBAL <= Scope.GLOBAL
  31. assert Scope.CYCLE <= Scope.GLOBAL
  32. assert Scope.CYCLE <= Scope.CYCLE
  33. assert Scope.SCENARIO <= Scope.GLOBAL
  34. assert Scope.SCENARIO <= Scope.CYCLE
  35. assert Scope.SCENARIO <= Scope.SCENARIO
  36. with pytest.raises(TypeError):
  37. assert Scope.SCENARIO <= "testing string"
  38. # Test __lt__ method
  39. assert Scope.SCENARIO < Scope.GLOBAL
  40. assert Scope.SCENARIO < Scope.GLOBAL
  41. assert Scope.SCENARIO < Scope.CYCLE
  42. with pytest.raises(TypeError):
  43. assert Scope.SCENARIO < "testing string"