Commit b7af0cedf46a54d322be6758106464d984446e0c

Authored by OrysiaDrabych
1 parent 2373656b

Add additional classifications for all items

... ... @@ -120,6 +120,7 @@ class OP_Provider(BaseProvider):
120 120 from a specific cpv group. Cpv group is three digits
121 121 in the beginning of each cpv id.
122 122 """
  123 + item_base_data = None
123 124 if cpv_group is None:
124 125 item_base_data = self.random_element(self.items_base_data)
125 126 else:
... ... @@ -133,12 +134,16 @@ class OP_Provider(BaseProvider):
133 134 if entity["cpv_id"] == cpv:
134 135 item_base_data = entity
135 136 break
  137 + if not item_base_data:
  138 + raise ValueError('unable to find an item with CPV ' + cpv)
136 139
137 140 # choose appropriate additional classification for item_base_data's cpv
138 141 additional_class = []
139 142 for entity in self.classifications:
140 143 if entity["classification"]["id"] == item_base_data["cpv_id"]:
141 144 additional_class.append(entity)
  145 + if not additional_class:
  146 + raise ValueError('unable to find a matching additional classification for CPV ' + cpv)
142 147 classification = self.random_element(additional_class)
143 148
144 149 dk_descriptions = {
... ... @@ -148,6 +153,7 @@ class OP_Provider(BaseProvider):
148 153 }
149 154 address = self.random_element(self.addresses)
150 155 item = {
  156 + "additionalClassifications": classification["additionalClassifications"],
151 157 "classification": classification["classification"],
152 158 "deliveryAddress": address["deliveryAddress"],
153 159 "deliveryLocation": address["deliveryLocation"],
... ... @@ -157,7 +163,6 @@ class OP_Provider(BaseProvider):
157 163 if item_base_data["cpv_id"] == "99999999-9":
158 164 scheme = classification["additionalClassifications"][0]["scheme"]
159 165 item.update({
160   - "additionalClassifications": classification["additionalClassifications"],
161 166 "description": dk_descriptions[scheme][0],
162 167 "description_ru": dk_descriptions[scheme][1],
163 168 "description_en": dk_descriptions[scheme][2]
... ...
Please register or login to post a comment