def patch_item_with_zero_quantity(self):
    self.create_tender()
    response = self.app.get("/tenders/{}".format(self.tender_id))
    item = response.json["data"]["items"][0]
    item["quantity"] = 0
    response = self.app.patch_json("/tenders/{}?acc_token={}".format(self.tender_id, self.tender_token),
                                   {"data": {"items": [item]}})
    self.assertEqual(response.status, "200 OK")
    self.assertEqual(response.content_type, "application/json")
    self.assertEqual(response.json["data"]["items"][0]["quantity"], 0)
    item = response.json["data"]["items"][0]
    item["quantity"] = 5
    response = self.app.patch_json("/tenders/{}?acc_token={}".format(self.tender_id, self.tender_token),
                                   {"data": {"items": [item]}})
    self.assertEqual(response.status, "200 OK")
    self.assertEqual(response.content_type, "application/json")
    self.assertEqual(response.json["data"]["items"][0]["quantity"], 5)
    criteria = deepcopy(test_criteria)
    criteria[0]["relatesTo"] = "item"
    criteria[0]["relatedItem"] = item["id"]
    add_criteria(self, criteria=criteria)
    item["quantity"] = 0
    response = self.app.patch_json("/tenders/{}?acc_token={}".format(self.tender_id, self.tender_token),
                                   {"data": {"items": [item]}})
    self.assertEqual(response.status, "200 OK")
示例#2
0
    def create_tender(self, initial_lots, features=None):
        auth = self.app.authorization
        self.app.authorization = ("Basic", ("competitive_dialogue", ""))
        data = deepcopy(self.initial_data)
        if initial_lots:
            lots = []
            for i in initial_lots:
                lot = deepcopy(i)
                if "id" not in lot:
                    lot["id"] = uuid4().hex
                lots.append(lot)
            data["lots"] = self.initial_lots = lots
            for i, item in enumerate(data["items"]):
                item["relatedLot"] = lots[i % len(lots)]["id"]
            for firm in data["shortlistedFirms"]:
                firm["lots"] = [dict(id=lot["id"]) for lot in lots]
            self.lots_id = [lot["id"] for lot in lots]
        if features:
            for feature in features:
                if feature["featureOf"] == "lot":
                    feature["relatedItem"] = data["lots"][0]["id"]
                if feature["featureOf"] == "item":
                    feature["relatedItem"] = data["items"][0]["id"]
            data["features"] = self.features = features
        response = self.app.post_json("/tenders", {"data": data})
        tender = response.json["data"]
        self.tender = tender
        self.tender_token = response.json["access"]["token"]
        self.tender_id = tender["id"]
        self.app.authorization = ("Basic", ("competitive_dialogue", ""))
        self.app.patch_json(
            "/tenders/{id}?acc_token={token}".format(id=self.tender_id,
                                                     token=self.tender_token),
            {"data": {
                "status": "draft.stage2"
            }},
        )

        add_criteria(self)

        self.app.authorization = ("Basic", ("broker", ""))
        self.app.patch_json(
            "/tenders/{id}?acc_token={token}".format(id=self.tender_id,
                                                     token=self.tender_token),
            {"data": {
                "status": "active.tendering"
            }},
        )
        self.app.authorization = auth
示例#3
0
 def set_tender_status(self, tender, token, status):
     auth = self.app.authorization
     if status == "draft.stage2":
         self.app.authorization = ("Basic", ("competitive_dialogue", ""))
         response = self.app.patch_json(
             "/tenders/{id}?acc_token={token}".format(id=tender["id"],
                                                      token=token),
             {"data": {
                 "status": status
             }})
         self.app.authorization = auth
         return response
     if status == "active.tendering":
         add_criteria(self, tender["id"], token)
         self.app.authorization = ("Basic", ("broker", ""))
         response = self.app.patch_json(
             "/tenders/{id}?acc_token={token}".format(id=tender["id"],
                                                      token=token),
             {"data": {
                 "status": status
             }})
         self.app.authorization = auth
         return response
示例#4
0
    def create_tender(self):
        data = deepcopy(self.initial_data)
        data["owner"] = self.first_owner
        with change_auth(self.app, ("Basic", ("competitive_dialogue", ""))):
            response = self.app.post_json("/tenders", {"data": data})
        self.assertEqual(response.status, "201 Created")
        self.assertEqual(response.content_type, "application/json")
        self.assertIn("transfer", response.json["access"])
        self.assertNotIn("transfer_token", response.json["data"])
        self.tender_id = response.json["data"]["id"]
        self.set_status("draft.stage2")

        response = self.app.patch_json(
            "/tenders/{}/credentials?acc_token={}".format(self.tender_id, test_access_token_stage1), {"data": ""}
        )
        self.tender_transfer = response.json["access"]["transfer"]
        tender_access_token = response.json["access"]["token"]

        add_criteria(self, tender_token=tender_access_token)

        response = self.app.patch_json(
            "/tenders/{}?acc_token={}".format(self.tender_id, tender_access_token),
            {"data": {"status": "active.tendering"}},
        )