25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

94 lines
3.5 KiB

  1. #!/usr/bin/env python3
  2. from .utils import (
  3. execute,
  4. KOSMORRO,
  5. )
  6. def test_timezone_with_command_line_arg():
  7. result = execute(KOSMORRO + ["--timezone=1", "-d2020-01-27"])
  8. assert result.successful
  9. assert "Note: All the hours are given in the UTC+1.0 timezone." in result.stdout
  10. result = execute(KOSMORRO + ["--timezone=Europe/Paris", "-d2020-01-27"])
  11. assert result.successful
  12. assert "Note: All the hours are given in the UTC+1.0 timezone." not in result.stdout
  13. result = execute(KOSMORRO + ["--timezone=-5", "-d2020-01-27"])
  14. assert result.successful
  15. assert "Note: All the hours are given in the UTC-5.0 timezone." in result.stdout
  16. result = execute(KOSMORRO + ["--timezone=America/Chicago", "-d2020-01-27"])
  17. assert result.successful
  18. assert "Note: All the hours are given in the UTC-5.0 timezone." in result.stdout
  19. def test_timezone_with_env_var():
  20. result = execute(KOSMORRO + ["-d2020-01-27"], environment={"TZ": "1"})
  21. assert result.successful
  22. assert "Note: All the hours are given in the UTC+1.0 timezone." in result.stdout
  23. result = execute(KOSMORRO + ["-d2020-01-27"], environment={"TZ": "Europe/Paris"})
  24. assert result.successful
  25. assert "Note: All the hours are given in the UTC+1.0 timezone." not in result.stdout
  26. result = execute(KOSMORRO + ["-d2020-01-27"], environment={"TZ": "-5"})
  27. assert result.successful
  28. assert "Note: All the hours are given in the UTC-5.0 timezone." in result.stdout
  29. result = execute(KOSMORRO + ["-d2020-01-27"], environment={"TZ": "America/Chicago"})
  30. assert result.successful
  31. assert "Note: All the hours are given in the UTC-5.0 timezone." in result.stdout
  32. def test_timezone_with_env_var_and_command_line_arg():
  33. result = execute(
  34. KOSMORRO + ["--timezone=3", "-d2020-01-27"], environment={"TZ": "Europe/Paris"}
  35. )
  36. assert result.successful
  37. assert "Note: All the hours are given in the UTC+3.0 timezone." in result.stdout
  38. def test_timezone_with_deprecated_env_var():
  39. result = execute(
  40. KOSMORRO + ["-d2020-01-27"], environment={"KOSMORRO_TIMEZONE": "1"}
  41. )
  42. assert result.successful
  43. assert (
  44. "Environment variable KOSMORRO_TIMEZONE is deprecated. Use TZ instead, which is more standard."
  45. in result.stderr
  46. )
  47. assert "Note: All the hours are given in the UTC+1.0 timezone." in result.stdout
  48. result = execute(
  49. KOSMORRO + ["-d2020-01-27"], environment={"KOSMORRO_TIMEZONE": "Europe/Paris"}
  50. )
  51. assert result.successful
  52. assert (
  53. "Environment variable KOSMORRO_TIMEZONE is deprecated. Use TZ instead, which is more standard."
  54. in result.stderr
  55. )
  56. assert "Note: All the hours are given in the UTC+1.0 timezone." not in result.stdout
  57. result = execute(
  58. KOSMORRO + ["-d2020-01-27"], environment={"KOSMORRO_TIMEZONE": "-5"}
  59. )
  60. assert result.successful
  61. assert (
  62. "Environment variable KOSMORRO_TIMEZONE is deprecated. Use TZ instead, which is more standard."
  63. in result.stderr
  64. )
  65. assert "Note: All the hours are given in the UTC-5.0 timezone." in result.stdout
  66. result = execute(
  67. KOSMORRO + ["-d2020-01-27"],
  68. environment={"KOSMORRO_TIMEZONE": "America/Chicago"},
  69. )
  70. assert result.successful
  71. assert (
  72. "Environment variable KOSMORRO_TIMEZONE is deprecated. Use TZ instead, which is more standard."
  73. in result.stderr
  74. )
  75. assert "Note: All the hours are given in the UTC-5.0 timezone." in result.stdout