...
|
...
|
@@ -12,19 +12,19 @@ from munch import munchify |
12
|
12
|
from op_faker import OP_Provider
|
13
|
13
|
from .local_time import get_now, TZ
|
14
|
14
|
|
15
|
|
-
|
16
|
15
|
fake_en = Factory.create(locale='en_US')
|
17
|
16
|
fake_ru = Factory.create(locale='ru_RU')
|
18
|
17
|
fake_uk = Factory.create(locale='uk_UA')
|
19
|
18
|
fake_uk.add_provider(OP_Provider)
|
20
|
19
|
fake = fake_uk
|
21
|
20
|
used_identifier_id = []
|
22
|
|
-mode_open = ["belowThreshold", "aboveThresholdUA", "aboveThresholdEU",
|
23
|
|
- "aboveThresholdUA.defense", "competitiveDialogueUA", "competitiveDialogueEU", "esco", "closeFrameworkAgreementUA"]
|
24
|
|
-mode_limited = ["reporting", "negotiation.quick", "negotiation"]
|
|
21
|
+mode_open = ["belowThreshold", "aboveThresholdUA", "aboveThresholdEU",
|
|
22
|
+ "aboveThresholdUA.defense", "competitiveDialogueUA", "competitiveDialogueEU", "esco",
|
|
23
|
+ "closeFrameworkAgreementUA"]
|
|
24
|
+mode_limited = ["reporting", "negotiation.quick", "negotiation"]
|
25
|
25
|
violationType = ["corruptionDescription", "corruptionProcurementMethodType", "corruptionChanges",
|
26
|
|
- "corruptionPublicDisclosure", "corruptionBiddingDocuments", "documentsForm",
|
27
|
|
- "corruptionAwarded", "corruptionCancelled", "corruptionContracting"]
|
|
26
|
+ "corruptionPublicDisclosure", "corruptionBiddingDocuments", "documentsForm",
|
|
27
|
+ "corruptionAwarded", "corruptionCancelled", "corruptionContracting"]
|
28
|
28
|
|
29
|
29
|
# This workaround fixes an error caused by missing "catch_phrase" class method
|
30
|
30
|
# for the "ru_RU" locale in Faker >= 0.7.4
|
...
|
...
|
@@ -106,10 +106,10 @@ def create_fake_period(days=0, hours=0, minutes=0): |
106
|
106
|
|
107
|
107
|
|
108
|
108
|
def subtraction(value1, value2):
|
109
|
|
- if "." in str (value1) or "." in str (value2):
|
110
|
|
- return (float (value1) - float (value2))
|
|
109
|
+ if "." in str(value1) or "." in str(value2):
|
|
110
|
+ return (float(value1) - float(value2))
|
111
|
111
|
else:
|
112
|
|
- return (int (value1) - int (value2))
|
|
112
|
+ return (int(value1) - int(value2))
|
113
|
113
|
|
114
|
114
|
|
115
|
115
|
def create_fake_value_amount():
|
...
|
...
|
@@ -132,7 +132,7 @@ def translate_country_en(country): |
132
|
132
|
|
133
|
133
|
|
134
|
134
|
def convert_amount(amount):
|
135
|
|
- return (("{:,}".format(float (amount))).replace(',',' ').replace('.',','))
|
|
135
|
+ return ("{:,}".format(float(amount))).replace(',', ' ').replace('.', ',')
|
136
|
136
|
|
137
|
137
|
|
138
|
138
|
def translate_country_ru(country):
|
...
|
...
|
@@ -201,7 +201,7 @@ def test_tender_data(params, |
201
|
201
|
accelerator = accelerator \
|
202
|
202
|
if accelerator else params['intervals']['accelerator']
|
203
|
203
|
data['procurementMethodDetails'] = 'quick, ' \
|
204
|
|
- 'accelerator={}'.format(accelerator)
|
|
204
|
+ 'accelerator={}'.format(accelerator)
|
205
|
205
|
data["procuringEntity"]["kind"] = "other"
|
206
|
206
|
if data.get("mode") == "test":
|
207
|
207
|
data["title"] = u"[ТЕСТУВАННЯ] {}".format(data["title"])
|
...
|
...
|
@@ -318,7 +318,7 @@ def test_tender_data_planning(params): |
318
|
318
|
"mode": "test",
|
319
|
319
|
"items": [],
|
320
|
320
|
"buyers": []
|
321
|
|
- }
|
|
321
|
+ }
|
322
|
322
|
data["procuringEntity"]["name"] = data["procuringEntity"]["identifier"]["legalName"]
|
323
|
323
|
buyers = test_buyers_data()
|
324
|
324
|
buyers["name"] = buyers["identifier"]["legalName"]
|
...
|
...
|
@@ -345,7 +345,8 @@ def test_tender_data_planning(params): |
345
|
345
|
item_data = test_item_data(id_cpv)
|
346
|
346
|
del item_data['deliveryAddress']
|
347
|
347
|
del item_data['deliveryLocation']
|
348
|
|
- item_data['deliveryDate']['endDate'] = (get_now() + timedelta(days=10)).replace(hour=0, minute=0, second=0, microsecond=0).isoformat()
|
|
348
|
+ item_data['deliveryDate']['endDate'] = (get_now() + timedelta(days=10)).replace(hour=0, minute=0, second=0,
|
|
349
|
+ microsecond=0).isoformat()
|
349
|
350
|
del item_data['deliveryDate']['startDate']
|
350
|
351
|
data['items'].append(item_data)
|
351
|
352
|
if params['mode'] in mode_open:
|
...
|
...
|
@@ -545,12 +546,12 @@ def test_bid_value(max_value_amount, vat_included): |
545
|
546
|
def test_bid_value_esco(tender_data):
|
546
|
547
|
annual_cost = []
|
547
|
548
|
for i in range(0, 21):
|
548
|
|
- cost=round(random.uniform(1, 100), 2)
|
|
549
|
+ cost = round(random.uniform(1, 100), 2)
|
549
|
550
|
annual_cost.append(cost)
|
550
|
551
|
if tender_data['fundingKind'] == "budget":
|
551
|
|
- yearly_percentage=round(random.uniform(0.01, float(tender_data['yearlyPaymentsPercentageRange'])), 5)
|
|
552
|
+ yearly_percentage = round(random.uniform(0.01, float(tender_data['yearlyPaymentsPercentageRange'])), 5)
|
552
|
553
|
else:
|
553
|
|
- yearly_percentage= 0.8
|
|
554
|
+ yearly_percentage = 0.8
|
554
|
555
|
# when tender fundingKind is budget, yearlyPaymentsPercentageRange should be less or equal 0.8, and more or equal 0
|
555
|
556
|
# when tender fundingKind is other, yearlyPaymentsPercentageRange should be equal 0.8
|
556
|
557
|
return munchify({
|
...
|
...
|
@@ -577,7 +578,9 @@ def test_bid_data_selection(data, index): |
577
|
578
|
})
|
578
|
579
|
bid.data['status'] = 'draft'
|
579
|
580
|
bid.data['parameters'] = data['agreements'][0]['contracts'][index]['parameters']
|
580
|
|
- bid.data['lotValues'] = [test_bid_value(data['agreements'][0]['contracts'][index]['value']['amount'], data['agreements'][0]['contracts'][index]['value']['valueAddedTaxIncluded'])]
|
|
581
|
+ bid.data['lotValues'] = [test_bid_value(data['agreements'][0]['contracts'][index]['value']['amount'],
|
|
582
|
+ data['agreements'][0]['contracts'][index]['value'][
|
|
583
|
+ 'valueAddedTaxIncluded'])]
|
581
|
584
|
return bid
|
582
|
585
|
|
583
|
586
|
|
...
|
...
|
@@ -605,8 +608,10 @@ def test_item_data(cpv=None): |
605
|
608
|
startDate = fake.random_int(min=1, max=30)
|
606
|
609
|
endDate = startDate + fake.random_int(min=1, max=7)
|
607
|
610
|
data["deliveryDate"] = {
|
608
|
|
- "startDate": (get_now() + timedelta(days=startDate)).astimezone(TZ).replace(hour=0, minute=0, second=0, microsecond=0).isoformat(),
|
609
|
|
- "endDate": (get_now() + timedelta(days=endDate)).astimezone(TZ).replace(hour=0, minute=0, second=0, microsecond=0).isoformat()
|
|
611
|
+ "startDate": (get_now() + timedelta(days=startDate)).astimezone(TZ).replace(hour=0, minute=0, second=0,
|
|
612
|
+ microsecond=0).isoformat(),
|
|
613
|
+ "endDate": (get_now() + timedelta(days=endDate)).astimezone(TZ).replace(hour=0, minute=0, second=0,
|
|
614
|
+ microsecond=0).isoformat()
|
610
|
615
|
}
|
611
|
616
|
data["deliveryAddress"]["countryName_en"] = translate_country_en(data["deliveryAddress"]["countryName"])
|
612
|
617
|
data["deliveryAddress"]["countryName_ru"] = translate_country_ru(data["deliveryAddress"]["countryName"])
|
...
|
...
|
@@ -698,7 +703,8 @@ def test_tender_data_openeu(params, submissionMethodDetails, plan_data): |
698
|
703
|
data['procuringEntity']['name_en'] = fake_en.name()
|
699
|
704
|
data['procuringEntity']['contactPoint']['name_en'] = fake_en.name()
|
700
|
705
|
data['procuringEntity']['contactPoint']['availableLanguage'] = "en"
|
701
|
|
- data['procuringEntity']['identifier']['legalName_en'] = u"Institution \"Vinnytsia City Council primary and secondary general school № 10\""
|
|
706
|
+ data['procuringEntity']['identifier'][
|
|
707
|
+ 'legalName_en'] = u"Institution \"Vinnytsia City Council primary and secondary general school № 10\""
|
702
|
708
|
data['procuringEntity']['kind'] = 'general'
|
703
|
709
|
return data
|
704
|
710
|
|
...
|
...
|
@@ -748,34 +754,34 @@ def test_tender_data_selection(procedure_intervals, params, submissionMethodDeta |
748
|
754
|
data['agreements'] = [{'id': tender_data['data']['agreements'][0]['id']}]
|
749
|
755
|
del data['value']
|
750
|
756
|
del data['minimalStep']
|
751
|
|
- return munchify({'data':data})
|
|
757
|
+ return munchify({'data': data})
|
752
|
758
|
|
753
|
759
|
|
754
|
760
|
def test_change_data():
|
755
|
761
|
return munchify(
|
756
|
|
- {
|
757
|
|
- "data":
|
758
|
762
|
{
|
759
|
|
- "rationale": fake.description(),
|
760
|
|
- "rationale_en": fake_en.sentence(nb_words=10, variable_nb_words=True),
|
761
|
|
- "rationale_ru": fake_ru.sentence(nb_words=10, variable_nb_words=True),
|
762
|
|
- "rationaleTypes": fake.rationaleTypes(amount=3),
|
763
|
|
- "status": "pending"
|
764
|
|
- }
|
765
|
|
- })
|
|
763
|
+ "data":
|
|
764
|
+ {
|
|
765
|
+ "rationale": fake.description(),
|
|
766
|
+ "rationale_en": fake_en.sentence(nb_words=10, variable_nb_words=True),
|
|
767
|
+ "rationale_ru": fake_ru.sentence(nb_words=10, variable_nb_words=True),
|
|
768
|
+ "rationaleTypes": fake.rationaleTypes(amount=3),
|
|
769
|
+ "status": "pending"
|
|
770
|
+ }
|
|
771
|
+ })
|
766
|
772
|
|
767
|
773
|
|
768
|
774
|
def test_agreement_change_data(rationaleType):
|
769
|
775
|
return munchify(
|
770
|
|
- {
|
771
|
|
- "data":
|
772
|
776
|
{
|
773
|
|
- "rationale": fake.description(),
|
774
|
|
- "rationale_en": fake_en.sentence(nb_words=10, variable_nb_words=True),
|
775
|
|
- "rationale_ru": fake_ru.sentence(nb_words=10, variable_nb_words=True),
|
776
|
|
- "rationaleType": rationaleType,
|
777
|
|
- }
|
778
|
|
- })
|
|
777
|
+ "data":
|
|
778
|
+ {
|
|
779
|
+ "rationale": fake.description(),
|
|
780
|
+ "rationale_en": fake_en.sentence(nb_words=10, variable_nb_words=True),
|
|
781
|
+ "rationale_ru": fake_ru.sentence(nb_words=10, variable_nb_words=True),
|
|
782
|
+ "rationaleType": rationaleType,
|
|
783
|
+ }
|
|
784
|
+ })
|
779
|
785
|
|
780
|
786
|
|
781
|
787
|
def test_modification_data(item_id, field_name, field_value):
|
...
|
...
|
@@ -787,24 +793,21 @@ def test_modification_data(item_id, field_name, field_value): |
787
|
793
|
}
|
788
|
794
|
]
|
789
|
795
|
}
|
790
|
|
- return munchify({'data':data})
|
|
796
|
+ return munchify({'data': data})
|
791
|
797
|
|
792
|
798
|
|
793
|
799
|
def get_hash(file_contents):
|
794
|
|
- return ("md5:"+hashlib.md5(file_contents).hexdigest())
|
|
800
|
+ return ("md5:" + hashlib.md5(file_contents).hexdigest())
|
795
|
801
|
|
796
|
802
|
|
797
|
|
-def tets_monitoring_data( tender_id, accelerator=None):
|
798
|
|
- data = {
|
799
|
|
- "reasons": [random.choice(["public", "fiscal", "indicator", "authorities", "media"])],
|
800
|
|
- "tender_id": tender_id,
|
801
|
|
- "procuringStages": [random.choice(["awarding", "contracting", "planning"])],
|
802
|
|
- "parties": [test_party()],
|
803
|
|
- "mode": "test"
|
804
|
|
- }
|
805
|
|
- data['monitoringDetails'] = 'quick, ' \
|
806
|
|
- 'accelerator={}'.format(accelerator)
|
807
|
|
- return munchify({'data':data})
|
|
803
|
+def test_monitoring_data(tender_id, accelerator=None):
|
|
804
|
+ data = {"reasons": [random.choice(["public", "fiscal", "indicator", "authorities", "media"])],
|
|
805
|
+ "tender_id": tender_id,
|
|
806
|
+ "procuringStages": [random.choice(["awarding", "contracting", "planning"])],
|
|
807
|
+ "parties": [test_party()],
|
|
808
|
+ "mode": "test",
|
|
809
|
+ 'monitoringDetails': 'quick, ' 'accelerator={}'.format(accelerator)}
|
|
810
|
+ return munchify({'data': data})
|
808
|
811
|
|
809
|
812
|
|
810
|
813
|
def test_party():
|
...
|
...
|
@@ -816,26 +819,26 @@ def test_party(): |
816
|
819
|
|
817
|
820
|
def test_dialogue():
|
818
|
821
|
return munchify(
|
819
|
|
- {
|
820
|
|
- "data":
|
821
|
822
|
{
|
822
|
|
- "title": fake_en.sentence(nb_words=10, variable_nb_words=True),
|
823
|
|
- "description": fake_en.sentence(nb_words=10, variable_nb_words=True)
|
824
|
|
- }
|
825
|
|
- })
|
|
823
|
+ "data":
|
|
824
|
+ {
|
|
825
|
+ "title": fake_en.sentence(nb_words=10, variable_nb_words=True),
|
|
826
|
+ "description": fake_en.sentence(nb_words=10, variable_nb_words=True)
|
|
827
|
+ }
|
|
828
|
+ })
|
826
|
829
|
|
827
|
830
|
|
828
|
831
|
def test_conclusion(violationOccurred, relatedParty_id):
|
829
|
832
|
return munchify(
|
830
|
|
- {
|
831
|
|
- "data": {
|
832
|
|
- "conclusion": {
|
833
|
|
- "violationOccurred": violationOccurred,
|
834
|
|
- "violationType": random.choice(violationType),
|
835
|
|
- "relatedParty": relatedParty_id,
|
|
833
|
+ {
|
|
834
|
+ "data": {
|
|
835
|
+ "conclusion": {
|
|
836
|
+ "violationOccurred": violationOccurred,
|
|
837
|
+ "violationType": random.choice(violationType),
|
|
838
|
+ "relatedParty": relatedParty_id,
|
|
839
|
+ }
|
836
|
840
|
}
|
837
|
|
- }
|
838
|
|
- })
|
|
841
|
+ })
|
839
|
842
|
|
840
|
843
|
|
841
|
844
|
def test_status_data(status, relatedParty_id=None):
|
...
|
...
|
@@ -890,7 +893,7 @@ def test_tender_data_esco(params, submissionMethodDetails, plan_data): |
890
|
893
|
if index == 0:
|
891
|
894
|
data['lots'][index]['minimalStepPercentage'] = data['minimalStepPercentage']
|
892
|
895
|
else:
|
893
|
|
- data['lots'][index]['minimalStepPercentage'] = round((float(data['minimalStepPercentage'])-0.0002), 5)
|
|
896
|
+ data['lots'][index]['minimalStepPercentage'] = round((float(data['minimalStepPercentage']) - 0.0002), 5)
|
894
|
897
|
if data['fundingKind'] == "budget":
|
895
|
898
|
data['lots'][index]['yearlyPaymentsPercentageRange'] = float(round(random.uniform(0.01, 0.8), 5))
|
896
|
899
|
else:
|
...
|
...
|
@@ -932,25 +935,25 @@ def percentage_generation(number_of_milestones): |
932
|
935
|
|
933
|
936
|
def invalid_INN_data():
|
934
|
937
|
return munchify({
|
935
|
|
- "scheme": "INN",
|
936
|
|
- "description": "Insulin (human)",
|
937
|
|
- "id": "insulin (human)"
|
|
938
|
+ "scheme": "INN",
|
|
939
|
+ "description": "Insulin (human)",
|
|
940
|
+ "id": "insulin (human)"
|
938
|
941
|
})
|
939
|
942
|
|
940
|
943
|
|
941
|
944
|
def invalid_cost_data():
|
942
|
945
|
return munchify({
|
943
|
|
- "scheme": "UA-ROAD",
|
944
|
|
- "id": "H-08",
|
945
|
|
- "description": "Бориспіль - Дніпро - Запоріжжя (через м. Кременчук) - Маріуполь"
|
|
946
|
+ "scheme": "UA-ROAD",
|
|
947
|
+ "id": "H-08",
|
|
948
|
+ "description": "Бориспіль - Дніпро - Запоріжжя (через м. Кременчук) - Маріуполь"
|
946
|
949
|
})
|
947
|
950
|
|
948
|
951
|
|
949
|
952
|
def invalid_gmdn_data():
|
950
|
953
|
return munchify({
|
951
|
|
- "scheme": "GMDN",
|
952
|
|
- "id": "10082",
|
953
|
|
- "description": "Змішувач амальгами для стоматології"
|
|
954
|
+ "scheme": "GMDN",
|
|
955
|
+ "id": "10082",
|
|
956
|
+ "description": "Змішувач амальгами для стоматології"
|
954
|
957
|
})
|
955
|
958
|
|
956
|
959
|
|
...
|
...
|
@@ -973,7 +976,7 @@ def invalid_buyers_data(): |
973
|
976
|
"legalName": "Київський Тестовий Ліцей",
|
974
|
977
|
},
|
975
|
978
|
"name": "Київський Тестовий Ліцей"
|
976
|
|
- }
|
|
979
|
+ }
|
977
|
980
|
return munchify(buyers)
|
978
|
981
|
|
979
|
982
|
|
...
|
...
|
@@ -1011,3 +1014,15 @@ def breakdown_value_generation(number_of_breakdown, plan_value): |
1011
|
1014
|
value_data = [round(random.uniform(1, plan_value / number_of_breakdown), 2) for _ in range(number_of_breakdown - 1)]
|
1012
|
1015
|
value_data.append(round(plan_value - sum(value_data), 2))
|
1013
|
1016
|
return value_data
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+def test_cancellation_data(procurement_method_type):
|
|
1020
|
+ if procurement_method_type == "aboveThresholdUA.defense":
|
|
1021
|
+ result = random.choice(["noDemand", "unFixable", "expensesCut"])
|
|
1022
|
+ elif procurement_method_type in ["negotiation", "negotiation.quick"]:
|
|
1023
|
+ result = random.choice(["noObjectiveness", "unFixable", "noDemand", "expensesCut", "dateViolation"])
|
|
1024
|
+ elif procurement_method_type == "belowThreshold":
|
|
1025
|
+ result = random.choice(["noDemand", "unFixable", "expensesCut"])
|
|
1026
|
+ else:
|
|
1027
|
+ result = random.choice(["noDemand", "unFixable", "forceMajeure", "expensesCut"])
|
|
1028
|
+ return munchify({"reasonType": result}) |
...
|
...
|
|