test_validate_id.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright 2021-2024 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 taipy.config.common._validate_id import _validate_id
  13. from taipy.config.exceptions.exceptions import InvalidConfigurationId
  14. class TestId:
  15. def test_validate_id(self):
  16. s = _validate_id("foo")
  17. assert s == "foo"
  18. with pytest.raises(InvalidConfigurationId):
  19. _validate_id("1foo")
  20. with pytest.raises(InvalidConfigurationId):
  21. _validate_id("foo bar")
  22. with pytest.raises(InvalidConfigurationId):
  23. _validate_id("foo/foo$")
  24. with pytest.raises(InvalidConfigurationId):
  25. _validate_id("")
  26. with pytest.raises(InvalidConfigurationId):
  27. _validate_id(" ")
  28. with pytest.raises(InvalidConfigurationId):
  29. _validate_id("class")
  30. with pytest.raises(InvalidConfigurationId):
  31. _validate_id("def")
  32. with pytest.raises(InvalidConfigurationId):
  33. _validate_id("with")
  34. with pytest.raises(InvalidConfigurationId):
  35. _validate_id("CYCLE")
  36. with pytest.raises(InvalidConfigurationId):
  37. _validate_id("SCENARIO")
  38. with pytest.raises(InvalidConfigurationId):
  39. _validate_id("SEQUENCE")
  40. with pytest.raises(InvalidConfigurationId):
  41. _validate_id("TASK")
  42. with pytest.raises(InvalidConfigurationId):
  43. _validate_id("DATANODE")