23
23
# -----------------------------------------------------------------------------
24
24
25
25
"""
26
- 2700 - Module for testing AQ
26
+ 2700 - Module for testing AQ with DbObject payloads.
27
27
"""
28
28
29
- import datetime
30
29
import decimal
31
30
import threading
32
31
import unittest
@@ -43,64 +42,6 @@ class TestCase(test_env.BaseTestCase):
43
42
("The Story of My Life" , "Hellen Keller" , decimal .Decimal ("10.50" )),
44
43
("The Chronicles of Narnia" , "C.S. Lewis" , decimal .Decimal ("25.25" )),
45
44
]
46
- json_queue_name = "TEST_JSON_QUEUE"
47
- json_data = [
48
- [
49
- 2.75 ,
50
- True ,
51
- "Ocean Beach" ,
52
- b"Some bytes" ,
53
- {"keyA" : 1.0 , "KeyB" : "Melbourne" },
54
- datetime .datetime (2022 , 8 , 1 , 0 , 0 ),
55
- ],
56
- [
57
- True ,
58
- False ,
59
- "String" ,
60
- b"Some Bytes" ,
61
- {},
62
- {"name" : None },
63
- {"name" : "John" },
64
- {"age" : 30 },
65
- {"Permanent" : True },
66
- {
67
- "employee" : {
68
- "name" : "John" ,
69
- "age" : 30 ,
70
- "city" : "Delhi" ,
71
- "Parmanent" : True ,
72
- }
73
- },
74
- {"employees" : ["John" , "Matthew" , "James" ]},
75
- {
76
- "employees" : [
77
- {"employee1" : {"name" : "John" , "city" : "Delhi" }},
78
- {"employee2" : {"name" : "Matthew" , "city" : "Mumbai" }},
79
- {"employee3" : {"name" : "James" , "city" : "Bangalore" }},
80
- ]
81
- },
82
- ],
83
- [
84
- datetime .datetime .today (),
85
- datetime .datetime (2004 , 2 , 1 , 3 , 4 , 5 ),
86
- datetime .datetime (2020 , 12 , 2 , 13 , 29 , 14 ),
87
- datetime .timedelta (8.5 ),
88
- datetime .datetime (2002 , 12 , 13 , 9 , 36 , 0 ),
89
- oracledb .Timestamp (2002 , 12 , 13 , 9 , 36 , 0 ),
90
- datetime .datetime (2002 , 12 , 13 ),
91
- ],
92
- dict (name = "John" , age = 30 , city = "New York" ),
93
- [
94
- 0 ,
95
- 1 ,
96
- 25.25 ,
97
- 6088343244 ,
98
- - 9999999999999999999 ,
99
- decimal .Decimal ("0.25" ),
100
- decimal .Decimal ("10.25" ),
101
- decimal .Decimal ("319438950232418390.273596" ),
102
- ],
103
- ]
104
45
105
46
def __deq_in_thread (self , results ):
106
47
with test_env .get_connection () as conn :
@@ -537,33 +478,7 @@ def notification_callback(message):
537
478
conn .unsubscribe (sub )
538
479
539
480
def test_2721 (self ):
540
- "2721 - test enqueuing and dequeuing JSON payloads"
541
- queue = self .get_and_clear_queue (self .json_queue_name , "JSON" )
542
- self .assertEqual (queue .payload_type , "JSON" )
543
- for data in self .json_data :
544
- props = self .conn .msgproperties (payload = data )
545
- queue .enqone (props )
546
- self .conn .commit ()
547
- queue .deqoptions .wait = oracledb .DEQ_NO_WAIT
548
- results = []
549
- while True :
550
- props = queue .deqone ()
551
- if props is None :
552
- break
553
- results .append (props .payload )
554
- self .conn .commit ()
555
- self .assertEqual (results , self .json_data )
556
-
557
- def test_2722 (self ):
558
- "2722 - test enqueuing to a JSON queue without a JSON payload"
559
- queue = self .get_and_clear_queue (self .json_queue_name , "JSON" )
560
- string_message = "This is a string message"
561
- props = self .conn .msgproperties (payload = string_message )
562
- with self .assertRaisesFullCode ("DPY-2062" ):
563
- queue .enqone (props )
564
-
565
- def test_2723 (self ):
566
- "2723 - test message props enqtime"
481
+ "2721 - test message props enqtime"
567
482
queue = self .get_and_clear_queue (
568
483
self .book_queue_name , self .book_type_name
569
484
)
@@ -579,8 +494,8 @@ def test_2723(self):
579
494
end_date = end_date .replace (microsecond = 0 )
580
495
self .assertTrue (start_date <= props .enqtime <= end_date )
581
496
582
- def test_2724 (self ):
583
- "2724 - test message props declared attributes"
497
+ def test_2722 (self ):
498
+ "2722 - test message props declared attributes"
584
499
queue = self .get_and_clear_queue (
585
500
self .book_queue_name , self .book_type_name
586
501
)
@@ -597,29 +512,29 @@ def test_2724(self):
597
512
for attr_name in values :
598
513
self .assertEqual (getattr (props , attr_name ), values [attr_name ])
599
514
600
- def test_2725 (self ):
601
- "2725 - test error for invalid type for payload_type"
515
+ def test_2723 (self ):
516
+ "2723 - test error for invalid type for payload_type"
602
517
self .assertRaises (
603
518
TypeError , self .conn .queue , "THE QUEUE" , payload_type = 4
604
519
)
605
520
606
- def test_2726 (self ):
607
- "2726 - test setting bytes to payload"
521
+ def test_2724 (self ):
522
+ "2724 - test setting bytes to payload"
608
523
props = self .conn .msgproperties ()
609
524
bytes_val = b"Hello there"
610
525
props .payload = bytes_val
611
526
self .assertEqual (props .payload , bytes_val )
612
527
613
- def test_2727 (self ):
614
- "2727 - test getting queue attributes"
528
+ def test_2725 (self ):
529
+ "2725 - test getting queue attributes"
615
530
queue = self .get_and_clear_queue (
616
531
self .book_queue_name , self .book_type_name
617
532
)
618
533
self .assertEqual (queue .name , self .book_queue_name )
619
534
self .assertEqual (queue .connection , self .conn )
620
535
621
- def test_2728 (self ):
622
- "2728 - test getting write-only attributes"
536
+ def test_2726 (self ):
537
+ "2726 - test getting write-only attributes"
623
538
queue = self .get_and_clear_queue (
624
539
self .book_queue_name , self .book_type_name
625
540
)
@@ -628,8 +543,8 @@ def test_2728(self):
628
543
with self .assertRaises (AttributeError ):
629
544
queue .deqoptions .deliverymode
630
545
631
- def test_2729 (self ):
632
- "2729 - test correlation deqoption"
546
+ def test_2727 (self ):
547
+ "2727 - test correlation deqoption"
633
548
queue = self .get_and_clear_queue (
634
549
self .book_queue_name , self .book_type_name
635
550
)
@@ -655,8 +570,8 @@ def test_2729(self):
655
570
correlated_messages = queue .deqmany (num_messages + 1 )
656
571
self .assertEqual (len (correlated_messages ), num_messages )
657
572
658
- def test_2730 (self ):
659
- "2730 - test correlation deqoption with pattern-matching characters"
573
+ def test_2728 (self ):
574
+ "2728 - test correlation deqoption with pattern-matching characters"
660
575
queue = self .get_and_clear_queue (
661
576
self .book_queue_name , self .book_type_name
662
577
)
@@ -672,8 +587,8 @@ def test_2730(self):
672
587
messages = queue .deqmany (5 )
673
588
self .assertEqual (len (messages ), 2 )
674
589
675
- def test_2731 (self ):
676
- "2731 - test condition deqoption with priority"
590
+ def test_2729 (self ):
591
+ "2729 - test condition deqoption with priority"
677
592
queue = self .get_and_clear_queue (
678
593
self .book_queue_name , self .book_type_name
679
594
)
@@ -699,8 +614,8 @@ def test_2731(self):
699
614
data = book .TITLE , book .AUTHORS , book .PRICE
700
615
self .assertEqual (data , self .book_data [ix ])
701
616
702
- def test_2732 (self ):
703
- "2732 - test mode deqoption with DEQ_REMOVE_NODATA"
617
+ def test_2730 (self ):
618
+ "2730 - test mode deqoption with DEQ_REMOVE_NODATA"
704
619
queue = self .get_and_clear_queue (
705
620
self .book_queue_name , self .book_type_name
706
621
)
@@ -720,42 +635,39 @@ def test_2732(self):
720
635
self .assertIsNone (message .payload .AUTHORS )
721
636
self .assertIsNone (message .payload .PRICE )
722
637
723
- def test_2733 (self ):
724
- "2733 - test payload_type returns the correct value"
638
+ def test_2731 (self ):
639
+ "2731 - test payload_type returns the correct value"
725
640
books_type = self .conn .gettype (self .book_type_name )
726
641
queue = self .conn .queue (self .book_queue_name , books_type )
727
642
self .assertEqual (queue .payload_type , books_type )
728
643
729
- queue = self .conn .queue ("TEST_RAW_QUEUE" )
730
- self .assertIsNone (queue .payload_type )
731
-
732
- def test_2734 (self ):
733
- "2734 - test deprecated attributes (enqOptions, deqOptions)"
734
- queue = self .get_and_clear_queue ("TEST_RAW_QUEUE" )
644
+ def test_2732 (self ):
645
+ "2732 - test deprecated attributes (enqOptions, deqOptions)"
646
+ books_type = self .conn .gettype (self .book_type_name )
647
+ queue = self .conn .queue (self .book_queue_name , books_type )
735
648
self .assertEqual (queue .enqOptions , queue .enqoptions )
736
649
self .assertEqual (queue .deqOptions , queue .deqoptions )
737
650
738
- def test_2735 (self ):
739
- "2735 - test deprecated AQ methods (enqOne, deqOne)"
740
- value = b"Test 2734"
741
- queue = self .get_and_clear_queue ("TEST_RAW_QUEUE" )
742
- queue .enqOne (self .conn .msgproperties (value ))
651
+ def test_2733 (self ):
652
+ "2733 - test deprecated AQ methods (enqOne, deqOne)"
653
+ books_type = self .conn .gettype (self .book_type_name )
654
+ queue = self .conn .queue (self .book_queue_name , books_type )
655
+ book = queue .payload_type .newobject ()
656
+ book .TITLE , book .AUTHORS , book .PRICE = self .book_data [0 ]
657
+ queue .enqOne (self .conn .msgproperties (book ))
743
658
props = queue .deqOne ()
744
- self .assertEqual (props .payload , value )
659
+ book = props .payload
660
+ results = (book .TITLE , book .AUTHORS , book .PRICE )
661
+ self .assertEqual (results , self .book_data [0 ])
745
662
746
- def test_2736 (self ):
747
- "2736 - test enqueuing to an object queue with the wrong payload"
663
+ def test_2734 (self ):
664
+ "2734 - test enqueuing to an object queue with the wrong payload"
748
665
queue = self .get_and_clear_queue (
749
666
self .book_queue_name , self .book_type_name
750
667
)
751
668
props = self .conn .msgproperties (payload = "A string" )
752
669
with self .assertRaisesFullCode ("DPY-2062" ):
753
670
queue .enqone (props )
754
- typ = self .conn .gettype ("UDT_SUBOBJECT" )
755
- obj = typ .newobject ()
756
- props = self .conn .msgproperties (payload = obj )
757
- with self .assertRaisesFullCode ("DPY-2062" ):
758
- queue .enqone (props )
759
671
760
672
761
673
if __name__ == "__main__" :
0 commit comments