Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

시간대에 종속적인 Datetime assertion Test #47

Open
soulee-dev opened this issue Aug 10, 2023 · 3 comments
Open

시간대에 종속적인 Datetime assertion Test #47

soulee-dev opened this issue Aug 10, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@soulee-dev
Copy link

soulee-dev commented Aug 10, 2023

서버에서는 UTC 시간대를 사용하여 모든 Test가 문제 없이 통과하지만,
Local에서 테스트 할때는 Datetime이 KST(Korean Standard Time)에 보정 되어 9시의 시차가 발생해 테스트를 실패함.

@soulee-dev
Copy link
Author

def test_timestamp(self):
    create_query = "CREATE TABLE test (test TIMESTAMP);"
    insert_query = "INSERT INTO test VALUES('1984-12-03 12:33:07')"
    event = self.create_and_insert_value(create_query, insert_query)
    self.assertEqual(event.rows[0]["values"]["test"].astimezone(datetime.timezone.utc),
                     datetime.datetime(1984, 12, 3, 12, 33, 7, tzinfo=datetime.timezone.utc))

이렇게 하면 보정이 가능하지만, 조금 더 나은 방법이 없을지 고민 필요.

@soulee-dev soulee-dev self-assigned this Aug 10, 2023
@soulee-dev soulee-dev added the bug Something isn't working label Aug 10, 2023
@dongwook-chan
Copy link

코드 상의 솔루션은 이렇게 하는 수 밖에 없을 것 같아요!
단, utc는 첫번째 인자에만 적용하면 될 것 같습니다~
MySQL에 입력된 TIMESTAMP형 컬럼값은 저희프로젝트에서 datetime.datetime.fromtimestamp({컬럼값 in unix time})로 resolve되는데요, fromtimestamp가 호스트 시스템의 시간대에 영향을 받아서 보정을 해버리는 케이스입니다.
두번째 인자에 쓰인 datetime.datetime은 시간대 정보가 들어가있지 않아서 보정이 일어나지는 않을 것 같네요!

우진님이 로컬 테스트 도커 컴포즈로 돌리는거 개발해주고 계신데
저희 프로젝트 자체도 도커로 띄워버린다면 프로젝트 돌아갈 서비스 설정을 UTC로 하면 해결될 것 같긴 한데 완벽한 솔루션이라고 할 수는 없을 것 같아요.

@soulee-dev
Copy link
Author

julien-duponchelle#442

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants