Browse Source

Use Status variables in tests

A recent change pushed API status definitions into a class:

  I93ee971125bc0c7a497e1fb839df38ebd38340e1

We can reuse this in the tests instead of duplicating the same
string across assertions.

Change-Id: I07a602a05f896d7cc70120bd89424e3c553baf9f
Lance Bragstad 1 year ago
parent
commit
9688b7938b
1 changed files with 39 additions and 35 deletions
  1. 39
    35
      keystoneauth1/tests/unit/test_discovery.py

+ 39
- 35
keystoneauth1/tests/unit/test_discovery.py View File

@@ -133,7 +133,7 @@ V3_AUTH_RESPONSE = json.dumps({
133 133
 CINDER_EXAMPLES = {
134 134
     "versions": [
135 135
         {
136
-            "status": "CURRENT",
136
+            "status": discover.Status.CURRENT,
137 137
             "updated": "2012-01-04T11:33:21Z",
138 138
             "id": "v1.0",
139 139
             "links": [
@@ -144,7 +144,7 @@ CINDER_EXAMPLES = {
144 144
             ]
145 145
         },
146 146
         {
147
-            "status": "CURRENT",
147
+            "status": discover.Status.CURRENT,
148 148
             "updated": "2012-11-21T11:33:21Z",
149 149
             "id": "v2.0",
150 150
             "links": [
@@ -155,7 +155,7 @@ CINDER_EXAMPLES = {
155 155
             ]
156 156
         },
157 157
         {
158
-            "status": "CURRENT",
158
+            "status": discover.Status.CURRENT,
159 159
             "updated": "2012-11-21T11:33:21Z",
160 160
             "id": "v3.0",
161 161
             "version": "3.27",
@@ -179,7 +179,7 @@ CINDER_EXAMPLES = {
179 179
 GLANCE_EXAMPLES = {
180 180
     "versions": [
181 181
         {
182
-            "status": "CURRENT",
182
+            "status": discover.Status.CURRENT,
183 183
             "id": "v2.2",
184 184
             "links": [
185 185
                 {
@@ -189,7 +189,7 @@ GLANCE_EXAMPLES = {
189 189
             ]
190 190
         },
191 191
         {
192
-            "status": "SUPPORTED",
192
+            "status": discover.Status.SUPPORTED,
193 193
             "id": "v2.1",
194 194
             "links": [
195 195
                 {
@@ -199,7 +199,7 @@ GLANCE_EXAMPLES = {
199 199
             ]
200 200
         },
201 201
         {
202
-            "status": "SUPPORTED",
202
+            "status": discover.Status.SUPPORTED,
203 203
             "id": "v2.0",
204 204
             "links": [
205 205
                 {
@@ -209,7 +209,7 @@ GLANCE_EXAMPLES = {
209 209
             ]
210 210
         },
211 211
         {
212
-            "status": "CURRENT",
212
+            "status": discover.Status.CURRENT,
213 213
             "id": "v1.1",
214 214
             "links": [
215 215
                 {
@@ -219,7 +219,7 @@ GLANCE_EXAMPLES = {
219 219
             ]
220 220
         },
221 221
         {
222
-            "status": "SUPPORTED",
222
+            "status": discover.Status.SUPPORTED,
223 223
             "id": "v1.0",
224 224
             "links": [
225 225
                 {
@@ -509,7 +509,7 @@ class VersionDataTests(utils.TestCase):
509 509
 
510 510
         for v in clean_data:
511 511
             self.assertEqual(v['version'], (3, 0))
512
-            self.assertEqual(v['status'], 'CURRENT')
512
+            self.assertEqual(v['status'], discover.Status.CURRENT)
513 513
             self.assertEqual(v['raw_status'], 'stable')
514 514
             self.assertEqual(v['url'], V3_URL)
515 515
 
@@ -523,7 +523,7 @@ class VersionDataTests(utils.TestCase):
523 523
                 "versions": [
524 524
                     dict(
525 525
                         {
526
-                            "status": "CURRENT",
526
+                            "status": discover.Status.CURRENT,
527 527
                             "id": "v2.2",
528 528
                             "links": [
529 529
                                 {
@@ -549,8 +549,8 @@ class VersionDataTests(utils.TestCase):
549 549
                             'collection': None,
550 550
                             'version': (2, 2),
551 551
                             'url': V3_URL,
552
-                            'status': 'CURRENT',
553
-                            'raw_status': 'CURRENT',
552
+                            'status': discover.Status.CURRENT,
553
+                            'raw_status': discover.Status.CURRENT,
554 554
                         },
555 555
                         **versions_out
556 556
                     )
@@ -799,7 +799,7 @@ class VersionDataTests(utils.TestCase):
799 799
         self.assertEqual(3, len(raw_data))
800 800
 
801 801
         for v in raw_data:
802
-            self.assertEqual(v['status'], 'CURRENT')
802
+            self.assertEqual(v['status'], discover.Status.CURRENT)
803 803
             if v['id'] == 'v1.0':
804 804
                 self.assertEqual(v['updated'], '2012-01-04T11:33:21Z')
805 805
             elif v['id'] == 'v2.0':
@@ -822,8 +822,8 @@ class VersionDataTests(utils.TestCase):
822 822
                 'not_before': None,
823 823
                 'version': (1, 0),
824 824
                 'url': v1_url,
825
-                'status': 'CURRENT',
826
-                'raw_status': 'CURRENT',
825
+                'status': discover.Status.CURRENT,
826
+                'raw_status': discover.Status.CURRENT,
827 827
             },
828 828
             {
829 829
                 'collection': None,
@@ -833,8 +833,8 @@ class VersionDataTests(utils.TestCase):
833 833
                 'not_before': None,
834 834
                 'version': (2, 0),
835 835
                 'url': v2_url,
836
-                'status': 'CURRENT',
837
-                'raw_status': 'CURRENT',
836
+                'status': discover.Status.CURRENT,
837
+                'raw_status': discover.Status.CURRENT,
838 838
             },
839 839
             {
840 840
                 'collection': BASE_URL,
@@ -844,8 +844,8 @@ class VersionDataTests(utils.TestCase):
844 844
                 'not_before': u'2019-12-31',
845 845
                 'version': (3, 0),
846 846
                 'url': v3_url,
847
-                'status': 'CURRENT',
848
-                'raw_status': 'CURRENT',
847
+                'status': discover.Status.CURRENT,
848
+                'raw_status': discover.Status.CURRENT,
849 849
             },
850 850
         ])
851 851
 
@@ -853,7 +853,7 @@ class VersionDataTests(utils.TestCase):
853 853
                         disc.versioned_data_for(min_version='v2.0',
854 854
                                                 max_version='v2.latest')):
855 855
             self.assertEqual((2, 0), version['version'])
856
-            self.assertEqual('CURRENT', version['raw_status'])
856
+            self.assertEqual(discover.Status.CURRENT, version['raw_status'])
857 857
             self.assertEqual(v2_url, version['url'])
858 858
 
859 859
         for version in (disc.data_for(1),
@@ -861,7 +861,7 @@ class VersionDataTests(utils.TestCase):
861 861
                             min_version=(1,),
862 862
                             max_version=(1, discover.LATEST))):
863 863
             self.assertEqual((1, 0), version['version'])
864
-            self.assertEqual('CURRENT', version['raw_status'])
864
+            self.assertEqual(discover.Status.CURRENT, version['raw_status'])
865 865
             self.assertEqual(v1_url, version['url'])
866 866
 
867 867
         self.assertIsNone(disc.url_for('v4'))
@@ -892,9 +892,9 @@ class VersionDataTests(utils.TestCase):
892 892
 
893 893
         for v in raw_data:
894 894
             if v['id'] in ('v2.2', 'v1.1'):
895
-                self.assertEqual(v['status'], 'CURRENT')
895
+                self.assertEqual(v['status'], discover.Status.CURRENT)
896 896
             elif v['id'] in ('v2.1', 'v2.0', 'v1.0'):
897
-                self.assertEqual(v['status'], 'SUPPORTED')
897
+                self.assertEqual(v['status'], discover.Status.SUPPORTED)
898 898
             else:
899 899
                 self.fail("Invalid version found")
900 900
 
@@ -910,8 +910,8 @@ class VersionDataTests(utils.TestCase):
910 910
                 'not_before': None,
911 911
                 'version': (1, 0),
912 912
                 'url': v1_url,
913
-                'status': 'SUPPORTED',
914
-                'raw_status': 'SUPPORTED',
913
+                'status': discover.Status.SUPPORTED,
914
+                'raw_status': discover.Status.SUPPORTED,
915 915
             },
916 916
             {
917 917
                 'collection': None,
@@ -921,8 +921,8 @@ class VersionDataTests(utils.TestCase):
921 921
                 'not_before': None,
922 922
                 'version': (1, 1),
923 923
                 'url': v1_url,
924
-                'status': 'CURRENT',
925
-                'raw_status': 'CURRENT',
924
+                'status': discover.Status.CURRENT,
925
+                'raw_status': discover.Status.CURRENT,
926 926
             },
927 927
             {
928 928
                 'collection': None,
@@ -932,8 +932,8 @@ class VersionDataTests(utils.TestCase):
932 932
                 'not_before': None,
933 933
                 'version': (2, 0),
934 934
                 'url': v2_url,
935
-                'status': 'SUPPORTED',
936
-                'raw_status': 'SUPPORTED',
935
+                'status': discover.Status.SUPPORTED,
936
+                'raw_status': discover.Status.SUPPORTED,
937 937
             },
938 938
             {
939 939
                 'collection': None,
@@ -943,8 +943,8 @@ class VersionDataTests(utils.TestCase):
943 943
                 'not_before': None,
944 944
                 'version': (2, 1),
945 945
                 'url': v2_url,
946
-                'status': 'SUPPORTED',
947
-                'raw_status': 'SUPPORTED',
946
+                'status': discover.Status.SUPPORTED,
947
+                'raw_status': discover.Status.SUPPORTED,
948 948
             },
949 949
             {
950 950
                 'collection': None,
@@ -954,8 +954,8 @@ class VersionDataTests(utils.TestCase):
954 954
                 'not_before': None,
955 955
                 'version': (2, 2),
956 956
                 'url': v2_url,
957
-                'status': 'CURRENT',
958
-                'raw_status': 'CURRENT',
957
+                'status': discover.Status.CURRENT,
958
+                'raw_status': discover.Status.CURRENT,
959 959
             },
960 960
         ])
961 961
 
@@ -965,7 +965,9 @@ class VersionDataTests(utils.TestCase):
965 965
                                 min_version=ver,
966 966
                                 max_version=(2, discover.LATEST))):
967 967
                 self.assertEqual((2, 2), version['version'])
968
-                self.assertEqual('CURRENT', version['raw_status'])
968
+                self.assertEqual(
969
+                    discover.Status.CURRENT, version['raw_status']
970
+                )
969 971
                 self.assertEqual(v2_url, version['url'])
970 972
                 self.assertEqual(v2_url, disc.url_for(ver))
971 973
 
@@ -975,7 +977,9 @@ class VersionDataTests(utils.TestCase):
975 977
                                 min_version=ver,
976 978
                                 max_version=(1, discover.LATEST))):
977 979
                 self.assertEqual((1, 1), version['version'])
978
-                self.assertEqual('CURRENT', version['raw_status'])
980
+                self.assertEqual(
981
+                    discover.Status.CURRENT, version['raw_status']
982
+                )
979 983
                 self.assertEqual(v1_url, version['url'])
980 984
                 self.assertEqual(v1_url, disc.url_for(ver))
981 985
 

Loading…
Cancel
Save