test_cos.py 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #
  2. # Copyright 2018-2022 Elyra Authors
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. from elyra.util.cos import join_paths
  17. def test_join_paths():
  18. """
  19. Verify that join_path yields the expected results
  20. """
  21. # one or more paths is None
  22. assert join_paths(None, None) == ""
  23. assert join_paths("", None) == ""
  24. assert join_paths(None, "") == ""
  25. assert join_paths("path", None) == "path"
  26. assert join_paths("/path", None) == "path"
  27. assert join_paths("path/", None) == "path"
  28. assert join_paths("/path/", None) == "path"
  29. # one or more paths is the empty string
  30. assert join_paths("", "") == ""
  31. assert join_paths("path", "") == "path"
  32. assert join_paths("/path", "") == "path"
  33. assert join_paths("path/", "") == "path"
  34. assert join_paths("/path/", "") == "path"
  35. assert join_paths("", "path") == "path"
  36. assert join_paths("", "/path") == "path"
  37. assert join_paths("", "path/") == "path"
  38. assert join_paths("", "/path/") == "path"
  39. assert join_paths("path", "path2") == "path/path2"
  40. assert join_paths("/path", "path2") == "path/path2"
  41. assert join_paths("path/", "path2") == "path/path2"
  42. assert join_paths("/path/", "path2") == "path/path2"
  43. assert join_paths("path", "/path2") == "path/path2"
  44. assert join_paths("path", "path2/") == "path/path2"
  45. assert join_paths("path", "/path2/") == "path/path2"
  46. assert join_paths("/path", "/path2") == "path/path2"
  47. assert join_paths("/path", "path2/") == "path/path2"
  48. assert join_paths("/path", "/path2/") == "path/path2"
  49. assert join_paths("/path/", "/path2") == "path/path2"
  50. assert join_paths("/path/", "path2/") == "path/path2"
  51. assert join_paths("/path/", "/path2/") == "path/path2"
  52. # multiple //
  53. assert join_paths("//path", "path2") == "path/path2"
  54. assert join_paths("path//", "path2") == "path/path2"
  55. assert join_paths("//path//", "path2") == "path/path2"
  56. assert join_paths("path", "//path2") == "path/path2"
  57. assert join_paths("path", "path2//") == "path/path2"
  58. assert join_paths("path", "//path2//") == "path/path2"
  59. assert join_paths("//path", "//path2") == "path/path2"
  60. assert join_paths("//path", "path2//") == "path/path2"
  61. assert join_paths("//path", "//path2//") == "path/path2"
  62. assert join_paths("//path//", "//path2") == "path/path2"
  63. assert join_paths("//path//", "path2//") == "path/path2"
  64. assert join_paths("//path//", "//path2//") == "path/path2"