1
1
import json
2
2
import pytest
3
+ from base64 import b64encode
3
4
from uuid import UUID
4
5
from six import iteritems
5
6
30
31
31
32
class TestPetstore (object ):
32
33
34
+ api_key = b'12345'
35
+
36
+ @property
37
+ def api_key_encoded (self ):
38
+ return b64encode (self .api_key )
39
+
33
40
@pytest .fixture
34
41
def spec_dict (self , factory ):
35
42
return factory .spec_from_file ("data/v3.0/petstore.yaml" )
@@ -424,7 +431,7 @@ def test_post_birds(self, spec, spec_dict):
424
431
}
425
432
data = json .dumps (data_json )
426
433
headers = {
427
- 'api_key' : '12345' ,
434
+ 'api_key' : self . api_key_encoded ,
428
435
}
429
436
cookies = {
430
437
'user' : '123' ,
@@ -440,7 +447,7 @@ def test_post_birds(self, spec, spec_dict):
440
447
441
448
assert parameters == {
442
449
'header' : {
443
- 'api_key' : 12345 ,
450
+ 'api_key' : self . api_key ,
444
451
},
445
452
'cookie' : {
446
453
'user' : 123 ,
@@ -484,7 +491,7 @@ def test_post_cats(self, spec, spec_dict):
484
491
}
485
492
data = json .dumps (data_json )
486
493
headers = {
487
- 'api_key' : '12345' ,
494
+ 'api_key' : self . api_key_encoded ,
488
495
}
489
496
cookies = {
490
497
'user' : '123' ,
@@ -500,7 +507,7 @@ def test_post_cats(self, spec, spec_dict):
500
507
501
508
assert parameters == {
502
509
'header' : {
503
- 'api_key' : 12345 ,
510
+ 'api_key' : self . api_key ,
504
511
},
505
512
'cookie' : {
506
513
'user' : 123 ,
@@ -544,7 +551,7 @@ def test_post_cats_boolean_string(self, spec, spec_dict):
544
551
}
545
552
data = json .dumps (data_json )
546
553
headers = {
547
- 'api_key' : '12345' ,
554
+ 'api_key' : self . api_key_encoded ,
548
555
}
549
556
cookies = {
550
557
'user' : '123' ,
@@ -560,7 +567,7 @@ def test_post_cats_boolean_string(self, spec, spec_dict):
560
567
561
568
assert parameters == {
562
569
'header' : {
563
- 'api_key' : 12345 ,
570
+ 'api_key' : self . api_key ,
564
571
},
565
572
'cookie' : {
566
573
'user' : 123 ,
@@ -592,7 +599,7 @@ def test_post_no_one_of_schema(self, spec, spec_dict):
592
599
}
593
600
data = json .dumps (data_json )
594
601
headers = {
595
- 'api_key' : '12345' ,
602
+ 'api_key' : self . api_key_encoded ,
596
603
}
597
604
cookies = {
598
605
'user' : '123' ,
@@ -608,7 +615,7 @@ def test_post_no_one_of_schema(self, spec, spec_dict):
608
615
609
616
assert parameters == {
610
617
'header' : {
611
- 'api_key' : 12345 ,
618
+ 'api_key' : self . api_key ,
612
619
},
613
620
'cookie' : {
614
621
'user' : 123 ,
@@ -631,7 +638,7 @@ def test_post_cats_only_required_body(self, spec, spec_dict):
631
638
}
632
639
data = json .dumps (data_json )
633
640
headers = {
634
- 'api_key' : '12345' ,
641
+ 'api_key' : self . api_key_encoded ,
635
642
}
636
643
cookies = {
637
644
'user' : '123' ,
@@ -647,7 +654,7 @@ def test_post_cats_only_required_body(self, spec, spec_dict):
647
654
648
655
assert parameters == {
649
656
'header' : {
650
- 'api_key' : 12345 ,
657
+ 'api_key' : self . api_key ,
651
658
},
652
659
'cookie' : {
653
660
'user' : 123 ,
@@ -672,7 +679,7 @@ def test_post_pets_raises_invalid_mimetype(self, spec):
672
679
}
673
680
data = json .dumps (data_json )
674
681
headers = {
675
- 'api_key' : '12345' ,
682
+ 'api_key' : self . api_key_encoded ,
676
683
}
677
684
cookies = {
678
685
'user' : '123' ,
@@ -688,7 +695,7 @@ def test_post_pets_raises_invalid_mimetype(self, spec):
688
695
689
696
assert parameters == {
690
697
'header' : {
691
- 'api_key' : 12345 ,
698
+ 'api_key' : self . api_key ,
692
699
},
693
700
'cookie' : {
694
701
'user' : 123 ,
@@ -711,7 +718,7 @@ def test_post_pets_missing_cookie(self, spec, spec_dict):
711
718
}
712
719
data = json .dumps (data_json )
713
720
headers = {
714
- 'api_key' : '12345' ,
721
+ 'api_key' : self . api_key_encoded ,
715
722
}
716
723
717
724
request = MockRequest (
0 commit comments