Beispiel #1
0
def test_esco_not_tendering_rates(test_data):
    base_amount, expected_complaint_amount = test_data
    complaint = Complaint(complaint_data)
    root = Mock(__parent__=None)
    root.request.validated = {
        "tender": {
            "revisions": [dict(date=(RELEASE_2020_04_19 + timedelta(days=1)).isoformat())],
            "status": "any but tendering and pre-qualification statuses",
            "procurementMethodType": "esco",
            "bids": [
                {
                    "owner_token": "122344",
                    "value": {
                        "amount": -1,
                        "currency": "UAH"
                    }
                },
                {
                    "owner_token": "secret_stuff",
                    "value": {
                        "amount": base_amount,
                        "currency": "UAH"
                    }
                }
            ]
        },
    }
    root.request.params = {"acc_token": "secret_stuff"}
    complaint["__parent__"] = root
    result = complaint.serialize()
    assert "value" in result
    assert result["value"] == {"currency": "UAH", "amount": expected_complaint_amount}
Beispiel #2
0
def test_award_lot_complaint_rate():
    root = Mock(__parent__=None)
    lot_id = "1" * 32
    root.request.validated = {
        "tender": {
            "revisions": [Mock(date=RELEASE_2020_04_19 + timedelta(days=1))],
            "status": "active.tendering",
            "procurementMethodType": "",
            "value": {
                "amount": 99999999999,
                "currency": "UAH",
            },
            "lots": [{
                "id": lot_id,
                "value": {
                    "amount": 1000,
                    "currency": "UAH"
                }
            }]
        },
    }
    award = Award(dict(id="0" * 32, lotID=lot_id))
    award["__parent__"] = root
    complaint = Complaint(complaint_data)
    complaint["__parent__"] = award
    result = complaint.serialize()
    assert "value" in result
    assert result["value"] == {
        "currency": "UAH",
        "amount": COMPLAINT_MIN_AMOUNT
    }
Beispiel #3
0
def test_esco_tendering(status):
    complaint = Complaint(complaint_data)
    root = Mock(__parent__=None)
    root.request.validated = {"tender": {
        "revisions": [dict(date=(RELEASE_2020_04_19 + timedelta(days=1)).isoformat())],
        "status": status,
        "procurementMethodType": "esco"
    }}
    complaint["__parent__"] = root

    result = complaint.serialize()
    assert "value" in result
    assert result["value"] == {"currency": "UAH", "amount": COMPLAINT_MIN_AMOUNT}
Beispiel #4
0
def test_post_not_uah_complaint_esco():
    """
    Esco with currency rates
    """
    complaint = Complaint(
        {
            "title": "complaint title",
            "status": "draft",
            "type": "complaint",
            "description": "complaint description",
            "author": test_author
        }
    )
    root = Mock(__parent__=None)
    root.request.validated = {
        "tender": {
            "revisions": [dict(date=(RELEASE_2020_04_19 + timedelta(days=1)).isoformat())],
            "status": "awarding",
            "procurementMethodType": "esco",
            "bids": [
                {
                    "owner_token": "122344",
                    "value": {"amount": -1, "currency": "UAH"}
                },
                {
                    "owner_token": "secret_stuff",
                    "value": {"amount": 70002, "currency": "USD"},
                }
            ]
        },
    }
    root.request.params = {"acc_token": "secret_stuff"}
    root.request.currency_rates = [
        {
            "cc": "USD",
            "rate": 8.0
        },
        {
            "cc": "EUR",
            "rate": 12.0
        }
    ]
    complaint["__parent__"] = root
    result = complaint.serialize()
    assert "value" in result
    # Converting 70002 USD into 560016.0 UAH using rate 8.0
    # 560016.0 * 0.6/100 = 3360.096 => 3370
    assert result["value"] == {'currency': 'UAH', 'amount': 3370}
Beispiel #5
0
def test_complaint_non_esco_tendering_rates(test_data):
    tender_amount, expected_complaint_amount = test_data
    complaint = Complaint(complaint_data)
    root = Mock(__parent__=None)
    root.request.validated = {"tender": {
        "revisions": [dict(date=(RELEASE_2020_04_19 + timedelta(days=1)).isoformat())],
        "status": "active.tendering",
        "procurementMethodType": "anything but esco",
        "value": {
            "amount": tender_amount,
            "currency": "UAH"
        }
    }}
    complaint["__parent__"] = root

    result = complaint.serialize()
    assert "value" in result
    assert result["value"] == {"currency": "UAH", "amount": expected_complaint_amount}
Beispiel #6
0
def test_esco_not_tendering_with_lot():
    amount, expected_amount = 901000, 5410
    complaint = Complaint(complaint_data)

    class MyMock(Mock):
        def get(self, key):
            return getattr(self, key)
    root = Mock(__parent__=None)
    cancellation = MyMock(__parent__=root, relatedLot="lot1", lotID=None)
    root.request.params = {"acc_token": "secret_stuff"}
    root.request.logging_context.items.return_value = ""
    root.request.validated = {"tender": {
        "revisions": [dict(date=(RELEASE_2020_04_19 + timedelta(days=1)).isoformat())],
        "status": "active.qualification",
        "procurementMethodType": "esco",
        "bids": [
            {
                "owner_token": "secret_stuff",
                "lotValues": [
                    {
                        "relatedLot": "lot1",
                        "value": {
                            "amount": amount,
                            "currency": "UAH"
                        }
                    }
                ],
                "tenderers": [{
                    "identifier": {
                        "scheme": "spam",
                        "id": "ham",
                    }
                }]
            },
        ],
        "lots": [
            {"id": "lot1"}
        ]
    }}
    complaint["__parent__"] = cancellation

    result = complaint.serialize()
    assert "value" in result
    assert result["value"] == {"currency": "UAH", "amount": expected_amount}
Beispiel #7
0
def test_post_draft_claim():
    """
    claims don't have value
    """
    complaint = Complaint(
        {
            "title": "complaint title",
            "status": "draft",
            "description": "complaint description",
            "author": test_author
        }
    )
    root = Mock(__parent__=None)
    root.request.validated = {"tender": {
        "status": "active.tendering",
        "procurementMethodType": "anything but esco",
        "value": {"amount": 1000}
    }}
    complaint["__parent__"] = root
    result = complaint.serialize()
    assert "value" not in result
Beispiel #8
0
def test_esco_not_tendering_rates(test_data):
    award_amount, expected_complaint_amount = test_data
    complaint = Complaint(complaint_data)
    root = Mock(__parent__=None)
    root.request.validated = {
        "tender": {
            "revisions": [Mock(date=RELEASE_2020_04_19 + timedelta(days=1))],
            "status": "any but tendering and pre-qualification.stand-still",
            "procurementMethodType": "esco"
        },
        "award": {
            "value": {
                "amount": award_amount,
                "currency": "UAH"
            }
        },
    }
    complaint["__parent__"] = root
    result = complaint.serialize()
    assert "value" in result
    assert result["value"] == {
        "currency": "UAH",
        "amount": expected_complaint_amount
    }
Beispiel #9
0
def test_post_not_uah_complaint():
    """
    applying currency rates
    """
    complaint = Complaint({
        "title": "complaint title",
        "status": "draft",
        "type": "complaint",
        "description": "complaint description",
        "author": test_author
    })
    root = Mock(__parent__=None)
    root.request.validated = {
        "tender": {
            "revisions": [Mock(date=RELEASE_2020_04_19 + timedelta(days=1))],
            "status": "active.tendering",
            "procurementMethodType": "anything but esco",
            "value": {
                "amount": 30001,
                "currency": "EUR"
            }
        }
    }
    root.request.currency_rates = [{
        "cc": "USD",
        "rate": 8.0
    }, {
        "cc": "EUR",
        "rate": 30.0
    }]
    complaint["__parent__"] = root
    result = complaint.serialize()
    assert "value" in result
    # 30001 * 30 = 900030
    # 900030 * 0.3 / 100 = 2700.09 => 2710
    assert result["value"] == {'currency': 'UAH', 'amount': 2710}
    def test_has_unanswered_complaints(self):
        tender = Tender(self.tender_data)
        tender.block_tender_complaint_status = ['pending']
        tender.lots = self.lots
        tender.complaints = [Complaint({
            'status': 'pending',
            'relatedLot': '11111111111111111111111111111111',
            'title': 'Earth is mine!'
        })]
        self.assertEqual(True, has_unanswered_complaints(tender))

        tender.complaints[0].relatedLot = '33333333333333333333333333333333'
        self.assertEqual(False, has_unanswered_complaints(tender))

        self.assertEqual(True, has_unanswered_complaints(tender, False))

        tender.complaints[0].status = 'resolved'
        self.assertEqual(False, has_unanswered_complaints(tender, False))
Beispiel #11
0
    def test_has_unanswered_complaints(self):
        tender = Tender(self.tender_data)
        tender.block_tender_complaint_status = ["pending"]
        tender.lots = self.lots
        tender.complaints = [
            Complaint(
                {"status": "pending", "relatedLot": "11111111111111111111111111111111", "title": "Earth is mine!"}
            )
        ]
        self.assertEqual(True, has_unanswered_complaints(tender))

        tender.complaints[0].relatedLot = "33333333333333333333333333333333"
        self.assertEqual(False, has_unanswered_complaints(tender))

        self.assertEqual(True, has_unanswered_complaints(tender, False))

        tender.complaints[0].status = "resolved"
        self.assertEqual(False, has_unanswered_complaints(tender, False))
Beispiel #12
0
def test_esco_lot_related_but_passed_acc_token_from_different_bid():
    """
    Tenderer provides his token from a bid with low amount to confuse the system
    we should find his another bid and related lotValue anyway
    :return:
    """
    complaint = Complaint(complaint_data)
    amount = 901000

    class MyMock(Mock):
        def get(self, key):
            return getattr(self, key)
    root = Mock(__parent__=None)
    cancellation = MyMock(__parent__=root, relatedLot="lot999", lotID=None)
    root.request.params = {"acc_token": "secret_stuff"}
    root.request.logging_context.items.return_value = ""
    root.request.validated = {"tender": {
        "revisions": [dict(date=(RELEASE_2020_04_19 + timedelta(days=1)).isoformat())],
        "status": "active.qualification",
        "procurementMethodType": "esco",
        "bids": [
            {
                "owner_token": "secret_stuff",
                "lotValues": [
                    {
                        "relatedLot": "lot1",
                        "value": {
                            "amount": 100,
                            "currency": "UAH"
                        }
                    }
                ],
                "tenderers": [{
                    "identifier": {
                        "scheme": "spam",
                        "id": "ham",
                    }
                }]
            },
            {
                "owner_token": "another_secret_stuff",
                "lotValues": [
                    {
                        "relatedLot": "lot999",
                        "value": {
                            "amount": amount,
                            "currency": "UAH"
                        }
                    }
                ],
                "tenderers": [{
                    "identifier": {
                        "scheme": "spam",
                        "id": "ham",
                    }
                }]
            },
        ],
        "lots": [
            {"id": "lot1"},
            {"id": "lot999"},
        ]
    }}
    complaint["__parent__"] = cancellation

    result = complaint.serialize()
    assert "value" in result
    assert result["value"] == {"currency": "UAH", "amount": round_up_to_ten(amount * COMPLAINT_ENHANCED_AMOUNT_RATE)}
Beispiel #13
0
def test_esco_lot_not_related_bidder():
    amount = 901000
    complaint = Complaint(complaint_data)

    class MyMock(Mock):
        def get(self, key):
            return getattr(self, key)
    root = Mock(__parent__=None)
    cancellation = MyMock(__parent__=root, relatedLot="lot999", lotID=None)
    root.request.params = {"acc_token": "secret_stuff"}
    root.request.logging_context.items.return_value = ""
    root.request.validated = {"tender": {
        "revisions": [dict(date=(RELEASE_2020_04_19 + timedelta(days=1)).isoformat())],
        "status": "active.qualification",
        "procurementMethodType": "esco",
        "bids": [
            {
                "owner_token": "secret_stuff",
                "lotValues": [
                    {
                        "relatedLot": "lot1",
                        "value": {
                            "amount": amount,  # included
                            "currency": "UAH"
                        }
                    }
                ],
                "tenderers": [{
                    "identifier": {
                        "scheme": "spam",
                        "id": "ham",
                    }
                }]
            },
            {
                "owner_token": "secret_stuff",
                "lotValues": [
                    {
                        "relatedLot": "lot1",
                        "value": {
                            "amount": amount,
                            "currency": "UAH"
                        }
                    }
                ],
                "tenderers": [{
                    "identifier": {
                        "scheme": "spam",
                        "id": "pork",
                    }
                }]
            },
            {
                "owner_token": "secret_stuff_2",
                "lotValues": [
                    {
                        "relatedLot": "lot2",
                        "value": {
                            "amount": amount,  # included
                            "currency": "UAH"
                        }
                    },
                    {
                        "relatedLot": "lot3",
                        "value": {
                            "amount": amount,  # included
                            "currency": "UAH"
                        }
                    }
                ],
                "tenderers": [{
                    "identifier": {
                        "scheme": "spam",
                        "id": "ham",
                    }
                }]
            }
        ],
        "lots": [
            {"id": "lot1"},
            {"id": "lot2"},
            {"id": "lot3"},
            {"id": "lot999"},
        ]
    }}
    complaint["__parent__"] = cancellation

    result = complaint.serialize()
    assert "value" in result
    assert result["value"] == {"currency": "UAH",
                               "amount": round_up_to_ten(3 * amount * COMPLAINT_ENHANCED_AMOUNT_RATE)}