6
6
import pytest
7
7
from pyodata .v2 .model import Schema , Typ , StructTypeProperty , Types , EntityType , EdmStructTypeSerializer , \
8
8
Association , AssociationSet , EndRole , AssociationSetEndRole , TypeInfo , MetadataBuilder , ParserError , PolicyWarning , \
9
- PolicyIgnore , Config , PolicyFatal , NullType , NullAssociation
9
+ PolicyIgnore , Config , PolicyFatal , NullType , NullAssociation , current_timezone
10
10
from pyodata .exceptions import PyODataException , PyODataModelError , PyODataParserError
11
11
from tests .conftest import assert_logging_policy
12
12
@@ -458,7 +458,7 @@ def test_traits_datetime():
458
458
459
459
# 1. direction Python -> OData
460
460
461
- testdate = datetime (2005 , 1 , 28 , 18 , 30 , 44 , 123456 , tzinfo = timezone . utc )
461
+ testdate = datetime (2005 , 1 , 28 , 18 , 30 , 44 , 123456 , tzinfo = current_timezone () )
462
462
assert typ .traits .to_literal (testdate ) == "datetime'2005-01-28T18:30:44.123456'"
463
463
464
464
# without miliseconds part
@@ -481,19 +481,22 @@ def test_traits_datetime():
481
481
assert testdate .minute == 33
482
482
assert testdate .second == 6
483
483
assert testdate .microsecond == 654321
484
+ assert testdate .tzinfo == current_timezone ()
484
485
485
486
# parsing without miliseconds
486
487
testdate = typ .traits .from_literal ("datetime'1976-11-23T03:33:06'" )
487
488
assert testdate .year == 1976
488
489
assert testdate .second == 6
489
490
assert testdate .microsecond == 0
491
+ assert testdate .tzinfo == current_timezone ()
490
492
491
493
# parsing without seconds and miliseconds
492
494
testdate = typ .traits .from_literal ("datetime'1976-11-23T03:33'" )
493
495
assert testdate .year == 1976
494
496
assert testdate .minute == 33
495
497
assert testdate .second == 0
496
498
assert testdate .microsecond == 0
499
+ assert testdate .tzinfo == current_timezone ()
497
500
498
501
# parsing invalid value
499
502
with pytest .raises (PyODataModelError ) as e_info :
@@ -515,19 +518,22 @@ def test_traits_datetime():
515
518
assert testdate .minute == 33
516
519
assert testdate .second == 6
517
520
assert testdate .microsecond == 10000
521
+ assert testdate .tzinfo == current_timezone ()
518
522
519
523
# parsing without miliseconds
520
524
testdate = typ .traits .from_json ("/Date(217567986000)/" )
521
525
assert testdate .year == 1976
522
526
assert testdate .second == 6
523
527
assert testdate .microsecond == 0
528
+ assert testdate .tzinfo == current_timezone ()
524
529
525
530
# parsing without seconds and miliseconds
526
531
testdate = typ .traits .from_json ("/Date(217567980000)/" )
527
532
assert testdate .year == 1976
528
533
assert testdate .minute == 33
529
534
assert testdate .second == 0
530
535
assert testdate .microsecond == 0
536
+ assert testdate .tzinfo == current_timezone ()
531
537
532
538
# parsing the lowest value
533
539
with pytest .raises (OverflowError ):
@@ -541,6 +547,7 @@ def test_traits_datetime():
541
547
assert testdate .minute == 0
542
548
assert testdate .second == 0
543
549
assert testdate .microsecond == 0
550
+ assert testdate .tzinfo == current_timezone ()
544
551
545
552
# parsing the highest value
546
553
with pytest .raises (OverflowError ):
@@ -554,6 +561,7 @@ def test_traits_datetime():
554
561
assert testdate .minute == 59
555
562
assert testdate .second == 59
556
563
assert testdate .microsecond == 999000
564
+ assert testdate .tzinfo == current_timezone ()
557
565
558
566
# parsing invalid value
559
567
with pytest .raises (PyODataModelError ) as e_info :
0 commit comments