Example #1
0
    def test_removing_pdf(self):
        attachment = Attachment(filename="sample.pdf", object_name="sample")
        to = TaskOrder(pdf=attachment)
        assert to.pdf is not None

        to.pdf = ""
        assert to.pdf is None
Example #2
0
    def test_draft_status(self, is_signed, is_completed):
        # Given that I have a TO that is neither completed nor signed
        to = TaskOrder()
        is_signed.return_value = False
        is_completed.return_value = False

        assert to.status == Status.DRAFT
Example #3
0
    def test_unsigned_status(self, is_signed, is_completed):
        # Given that I have a TO that is completed but not signed
        to = TaskOrder(signed_at=pendulum.now().subtract(days=1))
        is_completed.return_value = True
        is_signed.return_value = False

        # Its status should be unsigned
        assert to.status == Status.UNSIGNED
Example #4
0
    def test_expired_status(self, is_signed, is_completed, end_date,
                            start_date):
        # Given that I have a signed TO and today is after its expiration date
        to = TaskOrder()
        end_date.return_value = pendulum.today().subtract(days=1).date()
        start_date.return_value = pendulum.today().subtract(days=2).date()
        is_signed.return_value = True
        is_completed.return_value = True

        # Its status should be expired
        assert to.status == Status.EXPIRED
Example #5
0
    def test_upcoming_status(self, is_signed, is_completed, start_date,
                             end_date):
        # Given that I have a signed TO and today is before its start_date
        to = TaskOrder()
        start_date.return_value = pendulum.today().add(days=1).date()
        end_date.return_value = pendulum.today().add(days=2).date()
        is_signed.return_value = True
        is_completed.return_value = True

        # Its status should be upcoming
        assert to.status == Status.UPCOMING
Example #6
0
    def create(cls, creator, portfolio_id, number, clins, pdf):
        task_order = TaskOrder(portfolio_id=portfolio_id,
                               creator=creator,
                               number=number,
                               pdf=pdf)
        db.session.add(task_order)
        db.session.commit()

        TaskOrders.create_clins(task_order.id, clins)

        return task_order
Example #7
0
    def test_active_status(self, is_signed, is_completed, start_date,
                           end_date):
        # Given that I have a signed TO and today is within its start_date and end_date
        today = pendulum.today().date()
        to = TaskOrder()

        start_date.return_value = today.subtract(days=1)
        end_date.return_value = today.add(days=1)
        is_signed.return_value = True
        is_completed.return_value = True

        # Its status should be active
        assert to.status == Status.ACTIVE
Example #8
0
    def test_total_contract_amount(self):
        to = TaskOrder()
        assert to.total_contract_amount == 0

        clin1 = CLINFactory(task_order=to,
                            jedi_clin_type=JEDICLINType.JEDI_CLIN_1)
        clin2 = CLINFactory(task_order=to,
                            jedi_clin_type=JEDICLINType.JEDI_CLIN_2)
        clin3 = CLINFactory(task_order=to,
                            jedi_clin_type=JEDICLINType.JEDI_CLIN_3)

        assert (to.total_contract_amount == clin1.total_amount +
                clin2.total_amount + clin3.total_amount)
Example #9
0
    def test_total_obligated_funds(self):
        to = TaskOrder()
        assert to.total_obligated_funds == 0

        clin1 = CLINFactory(task_order=to,
                            jedi_clin_type=JEDICLINType.JEDI_CLIN_1)
        clin2 = CLINFactory(task_order=to,
                            jedi_clin_type=JEDICLINType.JEDI_CLIN_2)
        clin3 = CLINFactory(task_order=to,
                            jedi_clin_type=JEDICLINType.JEDI_CLIN_3)
        clin4 = CLINFactory(task_order=to,
                            jedi_clin_type=JEDICLINType.JEDI_CLIN_4)
        assert (to.total_obligated_funds == clin1.obligated_amount +
                clin2.obligated_amount + clin3.obligated_amount +
                clin4.obligated_amount)
Example #10
0
    def create(cls, portfolio_id, number, clins, pdf):
        task_order = TaskOrder(portfolio_id=portfolio_id,
                               number=number,
                               pdf=pdf)
        db.session.add(task_order)

        try:
            db.session.commit()
        except IntegrityError:
            db.session.rollback()
            raise AlreadyExistsError("task_order")

        TaskOrders.create_clins(task_order.id, clins)

        return task_order
Example #11
0
    def test_setting_pdf_with_empty_value(self):
        to = TaskOrder()
        assert to.pdf is None

        to.pdf = ""
        assert to.pdf is None
Example #12
0
 def test_setting_pdf_with_invalid_object(self):
     to = TaskOrder()
     with pytest.raises(TypeError):
         to.pdf = "invalid"
Example #13
0
 def test_setting_pdf_with_dictionary(self):
     to = TaskOrder()
     to.pdf = {"filename": PDF_FILENAME, "object_name": "123456"}
     assert to.pdf is not None
     assert to.pdf.filename == PDF_FILENAME
Example #14
0
    def test_setting_pdf_with_attachment(self):
        to = TaskOrder()
        attachment = Attachment(filename="sample.pdf", object_name="sample")
        to.pdf = attachment

        assert to.pdf_attachment_id == attachment.id