Example #1
0
 def test_milestone_get(self):
     contract, milestones = prepare_milestones(self)
     response = self.app.get(ENDPOINTS['milestones'].format(
         contract_id=contract.data.id, milestone_id=milestones[0]['id']))
     assert response.status == '200 OK', 'Cannot get milestone'
     assert response.json['data']['status'] == 'processing', \
         'Financing milestone must be created with status `processing`'
Example #2
0
    def test_patch_financing_milestone_without_document(self):
        contract, milestones = prepare_milestones(self, doc_preload=False)
        financing_milestone = Milestone(milestones[0])
        assert financing_milestone.type_ == 'financing'
        dateMet_to_set = financing_milestone.dueDate - timedelta(days=5)

        patch_milestone(self,
                        contract,
                        financing_milestone.id,
                        {'data': {
                            'dateMet': dateMet_to_set.isoformat()
                        }},
                        status=200)
Example #3
0
    def test_milestone_patch_financing_wrong_dateMet(self):
        contract, milestones = prepare_milestones(self)
        financing_milestone = Milestone(milestones[0])
        assert financing_milestone.type_ == 'financing'
        dateMet_to_set = financing_milestone.dueDate - timedelta(days=500)

        patch_milestone(self,
                        contract,
                        financing_milestone.id,
                        {'data': {
                            'dateMet': dateMet_to_set.isoformat()
                        }},
                        status=422)
Example #4
0
    def test_patch_notMet(self):
        contract, milestones = prepare_milestones(self)
        financing_milestone = Milestone(milestones[0])
        assert financing_milestone.type_ == 'financing'

        response = patch_milestone(
            self,
            contract,
            financing_milestone.id,
            {'data': {
                'status': 'notMet'
            }},
        )

        self.assertEqual(response.status, '200 OK')
        related_contract = get_contract(self, contract.data.id)
        self.assertEqual(related_contract.status, 'pending.unsuccessful')
Example #5
0
    def test_milestone_patch_attrs(self):
        contract, milestones = prepare_milestones(self)
        financing_milestone = Milestone(milestones[0])
        assert financing_milestone.type_ == 'financing'
        attrs = (
            'description_en',
            'description_ru',
            'title_en',
            'title_ru',
        )

        for attr in attrs:
            target_attr = uuid4().hex[:7]  # generate unique attr value
            patch_milestone(self, contract, financing_milestone.id,
                            {'data': {
                                attr: target_attr
                            }})

            patched_financing_milestone = get_milestone(
                self, contract.data.id, financing_milestone.id)
            assert getattr(patched_financing_milestone, attr) == target_attr
Example #6
0
    def test_milestone_patch_financing_dateMet_partially_met(self):
        contract, milestones = prepare_milestones(self)
        financing_milestone = Milestone(milestones[0])
        assert financing_milestone.type_ == 'financing'
        dateMet_to_set = financing_milestone.dueDate + timedelta(days=5)

        response = patch_milestone(
            self, contract, financing_milestone.id,
            {'data': {
                'dateMet': dateMet_to_set.isoformat()
            }})

        self.assertEqual(response.status, '200 OK')
        patched_financing_milestone = get_milestone(self, contract.data.id,
                                                    financing_milestone.id)
        assert patched_financing_milestone.dateMet == dateMet_to_set, 'dateMet was not set'
        assert patched_financing_milestone.status == 'partiallyMet', 'dateMet was not set'
        approval_milestone = get_milestone(self, contract.data.id,
                                           milestones[1]['id'])
        assert approval_milestone.status == 'processing'
        assert approval_milestone.dueDate is not None
        updated_contract = get_contract(self, contract.data.id)
        assert updated_contract.status == 'active.approval', 'Contract status was not updated'