-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtimestamp.py
More file actions
58 lines (56 loc) · 1.54 KB
/
timestamp.py
File metadata and controls
58 lines (56 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import pytest
from datetime import datetime
from cloudquery.sdk.scalar import Timestamp
import pandas as pd
@pytest.mark.parametrize(
"input_value,expected_scalar",
[
(
datetime.strptime("2006-01-02T15:04:05", "%Y-%m-%dT%H:%M:%S"),
Timestamp(
True,
pd.to_datetime("2006-01-02 15:04:05"),
),
),
(
"2006-01-02T15:04:05Z",
Timestamp(
True,
pd.to_datetime("2006-01-02 15:04:05Z"),
),
),
(
"2006-01-02T15:04:05Z07:00",
Timestamp(
True,
pd.to_datetime("2006-01-02T15:04:05Z07:00"),
),
),
(
"2006-01-02 15:04:05.999999999 -0700",
# "2006-01-02 15:04:05.999999999 -0700 MST",
Timestamp(
True,
pd.to_datetime("2006-01-02 15:04:05.999999999 -0700"),
),
),
(
"2006-01-02 15:04:05.999999999",
Timestamp(
True,
pd.to_datetime("2006-01-02 15:04:05.999999999"),
),
),
(
"2006-01-02 15:04:05.999999999Z",
Timestamp(
True,
pd.to_datetime("2006-01-02 15:04:05.999999999Z"),
),
),
],
)
def test_timestamp_set(input_value, expected_scalar):
b = Timestamp()
b.set(input_value)
assert b == expected_scalar, f"{b} and {expected_scalar} are not equal"