def test_is_brief_correct(self):
        brief = api_stubs.brief(user_id=123, status='live')['briefs']

        assert helpers.buyers_helpers.is_brief_correct(
            brief, 'digital-outcomes-and-specialists', 'digital-specialists', 123
        ) is True

        assert helpers.buyers_helpers.is_brief_correct(
            brief, 'not-digital-outcomes-and-specialists', 'digital-specialists', 123
        ) is False

        assert helpers.buyers_helpers.is_brief_correct(
            brief, 'digital-outcomes-and-specialists', 'not-digital-specialists', 123
        ) is False

        assert helpers.buyers_helpers.is_brief_correct(
            brief, 'digital-outcomes-and-specialists', 'not-digital-specialists', 124
        ) is False

        assert helpers.buyers_helpers.is_brief_correct(
            api_stubs.brief(user_id=123, status='withdrawn')['briefs'],
            'digital-outcomes-and-specialists',
            'digital-specialists',
            123
        ) is False
    def test_q_and_a_session_details(self, data_api_client):
        self.login()
        data_api_client.get_brief.return_value = api_stubs.brief(status='live')
        data_api_client.get_brief.return_value['briefs']['questionAndAnswerSessionDetails'] = 'SESSION DETAILS'

        res = self.client.get('/suppliers/opportunities/1/question-and-answer-session')
        assert res.status_code == 200
        assert 'SESSION DETAILS' in res.get_data(as_text=True)
    def test_q_and_a_session_details_checks_supplier_is_eligible(self, data_api_client):
        self.login()
        data_api_client.get_brief.return_value = api_stubs.brief(status='live')
        data_api_client.get_brief.return_value['briefs']['frameworkName'] = 'Digital Outcomes and Specialists'
        data_api_client.is_supplier_eligible_for_brief.return_value = False

        res = self.client.get('/suppliers/opportunities/1/question-and-answer-session')
        assert res.status_code == 400
    def test_submit_clarification_question_requires_live_brief(self, data_api_client):
        self.login(application_id=1)
        data_api_client.get_brief.return_value = api_stubs.brief(status='expired')

        res = self.client.post(self.url_for('main.ask_brief_clarification_question', brief_id=1), data={
            'csrf_token': FakeCsrf.valid_token,
        })
        assert res.status_code == 404
    def test_clarification_question_has_max_length_limit(self, data_api_client):
        self.login()
        data_api_client.get_brief.return_value = api_stubs.brief(status='live')

        res = self.client.post('/suppliers/opportunities/1/ask-a-question', data={
            'clarification-question': "a" * 5100,
        })
        assert res.status_code == 400
        assert "cannot be longer than" in res.get_data(as_text=True)
    def test_submit_empty_clarification_question_returns_validation_error(self, data_api_client):
        self.login()
        data_api_client.get_brief.return_value = api_stubs.brief(status='live')

        res = self.client.post('/suppliers/opportunities/1/ask-a-question', data={
            'clarification-question': "",
        })
        assert res.status_code == 400
        assert "cannot be empty" in res.get_data(as_text=True)
    def test_q_and_a_session_details_requires_selected_supplier(self, data_api_client):
        self.login(application_id=1)
        data_api_client.get_brief.return_value = api_stubs.brief(status='live')
        data_api_client.get_brief.return_value['briefs']['sellerSelector'] = 'someSellers'
        data_api_client.get_brief.return_value['briefs']['sellerEmailList'] = ['*****@*****.**']

        res = self.client.get(self.url_for('main.question_and_answer_session', brief_id=1))

        assert res.status_code == 400
    def test_clarification_question_has_max_word_limit(self, send_email, data_api_client):
        self.login()
        data_api_client.get_brief.return_value = api_stubs.brief(status='live')

        res = self.client.post('/suppliers/opportunities/1/ask-a-question', data={
            'clarification-question': "a " * 101,
        })
        assert res.status_code == 400
        assert "must be no more than 100 words" in res.get_data(as_text=True)
    def test_clarification_question_form(self, data_api_client):
        data_api_client.get_supplier.return_value = self.supplier()
        data_api_client.get_application.return_value = self.application()
        data_api_client.get_framework.return_value = self.framework()

        self.login(application_id=1)
        data_api_client.get_brief.return_value = api_stubs.brief(status='live')

        res = self.client.get(self.url_for('main.ask_brief_clarification_question', brief_id=1))
        assert res.status_code == 200
    def test_q_and_a_session_details(self, data_api_client):
        self.login(application_id=1)
        data_api_client.get_framework.return_value = self.framework
        data_api_client.get_supplier.return_value = self.supplier
        data_api_client.get_brief.return_value = api_stubs.brief(status='live')
        data_api_client.get_brief.return_value['briefs']['questionAndAnswerSessionDetails'] = 'SESSION DETAILS'

        res = self.client.get(self.url_for('main.question_and_answer_session', brief_id=1))
        assert res.status_code == 200
        assert 'SESSION DETAILS' in res.get_data(as_text=True)
 def setup(self):
     super(TestResponseResultPage, self).setup()
     lots = [api_stubs.lot(slug="digital-specialists", allows_brief=True)]
     self.framework = api_stubs.framework(status="live", slug="digital-outcomes-and-specialists",
                                          clarification_questions_open=False, lots=lots)
     self.brief = api_stubs.brief(status='live')
     self.brief['briefs']['essentialRequirements'] = ['Must one', 'Must two', 'Must three']
     self.brief['briefs']['evaluationType'] = ['Interview', 'Scenario or test', 'Presentation', 'Written proposal',
                                               'Work history']
     with self.app.test_client():
         self.login(application_id=1)
    def test_clarification_question_form_requires_selected_supplier(self, data_api_client):
        self.login(application_id=1)
        data_api_client.get_supplier.return_value = self.supplier()
        data_api_client.get_application.return_value = self.application()
        data_api_client.get_framework.return_value = self.framework()
        data_api_client.get_brief.return_value = api_stubs.brief(status='live')
        data_api_client.get_brief.return_value['briefs']['sellerSelector'] = 'someSellers'
        data_api_client.get_brief.return_value['briefs']['sellerEmailList'] = ['*****@*****.**']

        res = self.client.get(self.url_for('main.ask_brief_clarification_question', brief_id=1))
        assert res.status_code == 400
 def test_submit_empty_clarification_question_returns_validation_error(self, data_api_client):
     self.login(application_id=1)
     data_api_client.get_brief.return_value = api_stubs.brief(status='live')
     data_api_client.get_supplier.return_value = self.supplier()
     data_api_client.get_application.return_value = self.application()
     data_api_client.get_framework.return_value = self.framework()
     res = self.client.post(self.url_for('main.ask_brief_clarification_question', brief_id=1), data={
         'csrf_token': FakeCsrf.valid_token,
         'clarification-question': "",
     })
     assert res.status_code == 400
     assert "cannot be empty" in res.get_data(as_text=True)
 def test_clarification_question_has_max_word_limit(self, send_email, data_api_client):
     self.login(application_id=1)
     data_api_client.get_brief.return_value = api_stubs.brief(status='live')
     data_api_client.get_supplier.return_value = self.supplier()
     data_api_client.get_application.return_value = self.application()
     data_api_client.get_framework.return_value = self.framework()
     res = self.client.post(self.url_for('main.ask_brief_clarification_question', brief_id=1), data={
         'csrf_token': FakeCsrf.valid_token,
         'clarification-question': "a " * 101,
     })
     assert res.status_code == 400
     assert "must be no more than 100 words" in res.get_data(as_text=True)
    def test_submit_clarification_question_fails_on_mandrill_error(self, send_email, data_api_client):
        self.login()
        brief = api_stubs.brief(status="live")
        brief['briefs']['frameworkName'] = 'Framework Name'
        brief['briefs']['clarificationQuestionsPublishedBy'] = '2016-03-29T10:11:13.000000Z'
        data_api_client.get_brief.return_value = brief

        send_email.side_effect = Exception

        res = self.client.post('/suppliers/opportunities/1234/ask-a-question', data={
            'clarification-question': "important question",
        })
        assert res.status_code == 503
    def setup(self):
        super(TestRespondToBrief, self).setup()

        self.brief = api_stubs.brief(status='live')
        self.brief['briefs']['essentialRequirements'] = ['Essential one', 'Essential two', 'Essential three']
        self.brief['briefs']['niceToHaveRequirements'] = ['Nice one', 'Top one', 'Get sorted']

        lots = [api_stubs.lot(slug="digital-specialists", allows_brief=True)]
        self.framework = api_stubs.framework(status="live", slug="digital-outcomes-and-specialists",
                                             clarification_questions_open=False, lots=lots)

        with self.app.test_client():
            self.login()
    def setup(self):
        super(TestCreateResponseToBrief, self).setup()

        self.brief = api_stubs.brief(status='live', lot_slug='digital-specialists')
        self.brief['briefs']['essentialRequirements'] = ['Essential one', 'Essential two', 'Essential three']
        self.brief['briefs']['niceToHaveRequirements'] = ['Nice one', 'Top one', 'Get sorted']
        self.brief['briefs']['dates'] = {}
        self.brief['briefs']['dates']['closing_time'] = '2016-11-23T07:00:00+00:00'

        lots = [api_stubs.lot(slug="digital-specialists", allows_brief=True)]
        self.framework = api_stubs.framework(status="live", slug="digital-outcomes-and-specialists",
                                             clarification_questions_open=False, lots=lots)

        with self.app.test_client():
            self.login(application_id=1)
    def test_submit_clarification_question_fails_on_email_backend_error(self, send_email, data_api_client):
        self.login(application_id=1)
        brief = api_stubs.brief(status="live")
        brief['briefs']['frameworkName'] = 'Framework Name'
        brief['briefs']['clarificationQuestionsPublishedBy'] = '2016-03-29T10:11:13.000000Z'
        data_api_client.get_brief.return_value = brief
        data_api_client.get_supplier.return_value = self.supplier()
        data_api_client.get_application.return_value = self.application()
        data_api_client.get_framework.return_value = self.framework()
        send_email.side_effect = EmailError

        res = self.client.post(self.url_for('main.ask_brief_clarification_question', brief_id=1234), data={
            'csrf_token': FakeCsrf.valid_token,
            'clarification-question': "important question",
        })
        assert res.status_code == 503
 def test_submit_clarification_question_returns_error_page_if_ineligible_supplier_is_on_framework(
         self, send_email, data_api_client):
     self.login()
     data_api_client.get_brief.return_value = api_stubs.brief(status='live')
     data_api_client.get_brief.return_value['briefs']['frameworkName'] = 'Digital Outcomes and Specialists'
     data_api_client.is_supplier_eligible_for_brief.return_value = False
     data_api_client.get_supplier_framework_info.return_value = {
         'frameworkInterest': {'onFramework': True}
     }
     res = self.client.post('/suppliers/opportunities/1/ask-a-question', data={
         'clarification-question': "important question",
     })
     assert res.status_code == 400
     assert ERROR_MESSAGE_PAGE_HEADING_CLARIFICATION in res.get_data(as_text=True)
     assert ERROR_MESSAGE_DONT_PROVIDE_THIS_SERVICE_CLARIFICATION in res.get_data(as_text=True)
     assert not data_api_client.create_audit_event.called
    def test_submit_clarification_question(self, send_email, data_api_client):
        self.login(application_id=1)

        brief = api_stubs.brief(status="live")
        brief['briefs']['frameworkName'] = 'Brief Framework Name'
        brief['briefs']['clarificationQuestionsPublishedBy'] = '2016-03-29T10:11:13.000000Z'
        data_api_client.get_brief.return_value = brief
        data_api_client.get_supplier.return_value = self.supplier()
        data_api_client.get_application.return_value = self.application()
        data_api_client.get_framework.return_value = self.framework()
        res = self.client.post(self.url_for('main.ask_brief_clarification_question', brief_id=1234), data={
            'csrf_token': FakeCsrf.valid_token,
            'clarification-question': "important question",
        })
        assert res.status_code == 200

        send_email.assert_has_calls([
            mock.call(
                from_name='Brief Framework Name Supplier',
                email_body=FakeMail("important question"),
                from_email=self.app.config['CLARIFICATION_EMAIL_FROM'],
                to_email_addresses=['*****@*****.**'],
                subject=u"You\u2019ve received a new supplier question about \u2018I need a thing to do a thing\u2019"
            ),
            mock.call(
                from_name='Digital Marketplace Admin',
                email_body=FakeMail("important question"),
                from_email=self.app.config['CLARIFICATION_EMAIL_FROM'],
                to_email_addresses=['*****@*****.**'],
                subject=u"Your question about \u2018I need a thing to do a thing\u2019"
            ),
        ])

        data_api_client.create_audit_event.assert_called_with(
            audit_type=AuditTypes.send_clarification_question,
            object_type='briefs',
            data={'briefId': 1234, 'question': u'important question'},
            user='******',
            object_id=1234
        )
    def test_submit_clarification_question(self, send_email, data_api_client):
        self.login()
        brief = api_stubs.brief(status="live")
        brief['briefs']['frameworkName'] = 'Brief Framework Name'
        brief['briefs']['clarificationQuestionsPublishedBy'] = '2016-03-29T10:11:13.000000Z'
        data_api_client.get_brief.return_value = brief

        res = self.client.post('/suppliers/opportunities/1234/ask-a-question', data={
            'clarification-question': "important question",
        })
        assert res.status_code == 200

        send_email.assert_has_calls([
            mock.call(
                from_name='Brief Framework Name Supplier',
                tags=['brief-clarification-question'],
                email_body=FakeMail("important question"),
                from_email='*****@*****.**',
                to_email_addresses=['*****@*****.**'],
                subject=u"You\u2019ve received a new supplier question about \u2018I need a thing to do a thing\u2019"
            ),
            mock.call(
                from_name='Cirrus Admin',
                tags=['brief-clarification-question-confirmation'],
                email_body=FakeMail("important question"),
                from_email='*****@*****.**',
                to_email_addresses=['*****@*****.**'],
                subject=u"Your question about \u2018I need a thing to do a thing\u2019"
            ),
        ])

        data_api_client.create_audit_event.assert_called_with(
            audit_type=AuditTypes.send_clarification_question,
            object_type='briefs',
            data={'briefId': 1234, 'question': u'important question'},
            user='******',
            object_id=1234
        )
def test_brief():
    assert api_stubs.brief() \
        == {
        "briefs": {
            "id": 1234,
            "title": "I need a thing to do a thing",
            "frameworkSlug": "digital-outcomes-and-specialists",
            "frameworkName": "Digital Outcomes and Specialists",
            'frameworkFramework': 'digital-outcomes-and-specialists',
            "lotSlug": "digital-specialists",
            "status": "draft",
            "users": [{"active": True,
                       "role": "buyer",
                       "emailAddress": "*****@*****.**",
                       "id": 123,
                       "name": "Buyer User"}],
            "createdAt": "2016-03-29T10:11:12.000000+00:00",
            "updatedAt": "2016-03-29T10:11:13.000000+00:00",
            "clarificationQuestions": [],
            "sellerSelector": 'allSellers',
            "dates": {
                "answers_close": None,
                "application_open_weeks": "2 weeks",
                "closing_date": None,
                "closing_time": None,
                "hypothetical": {
                    "answers_close": "2016-10-19T07:00:00+00:00",
                    "application_open_weeks": "2 weeks",
                    "closing_date": "2016-10-20",
                    "closing_time": "2016-10-20T07:00:00+00:00",
                    "published_date": "2016-10-06",
                    "questions_close": "2016-10-13T07:00:00+00:00"
                },
                "published_date": None,
                "questions_close": None
            }
        }
    }

    assert api_stubs.brief(
        status='live',
        framework_slug='a-framework-slug',
        lot_slug='a-lot-slug', user_id=234,
        framework_name='A Framework Name') \
        == {
        "briefs": {
            "id": 1234,
            "title": "I need a thing to do a thing",
            "frameworkSlug": "a-framework-slug",
            "frameworkName": "A Framework Name",
            "frameworkFramework": "a-framework-slug",
            "lotSlug": "a-lot-slug",
            "status": "live",
            "users": [{"active": True,
                       "role": "buyer",
                       "emailAddress": "*****@*****.**",
                       "id": 234,
                       "name": "Buyer User"}],
            "createdAt": "2016-03-29T10:11:12.000000+00:00",
            "updatedAt": "2016-03-29T10:11:13.000000+00:00",
            "publishedAt": "2016-03-29T10:11:14.000000+00:00",
            "applicationsClosedAt": "2016-04-07T00:00:00.000000+00:00",
            "clarificationQuestionsClosedAt": "2016-04-02T00:00:00.000000+00:00",
            "clarificationQuestionsPublishedBy": "2016-04-06T00:00:00.000000+00:00",
            "clarificationQuestionsAreClosed": False,
            "clarificationQuestions": [],
            "sellerSelector": 'allSellers',
            "dates": {
              "answers_close": "2016-10-19T07:00:00+00:00",
              "application_open_weeks": "2 weeks",
              "closing_date": "2016-10-20",
              "closing_time": "2016-10-20T07:00:00+00:00",
              "published_date": "2016-10-06",
              "questions_close": "2016-10-13T07:00:00+00:00"
            }
        }
    }

    assert api_stubs.brief(clarification_questions=[{"question": "Why?", "answer": "Because"}]) \
        == {
        "briefs": {
            "id": 1234,
            "title": "I need a thing to do a thing",
            "frameworkSlug": "digital-outcomes-and-specialists",
            "frameworkFramework": "digital-outcomes-and-specialists",
            "frameworkName": "Digital Outcomes and Specialists",
            "lotSlug": "digital-specialists",
            "status": "draft",
            "users": [{"active": True,
                       "role": "buyer",
                       "emailAddress": "*****@*****.**",
                       "id": 123,
                       "name": "Buyer User"}],
            "createdAt": "2016-03-29T10:11:12.000000+00:00",
            "updatedAt": "2016-03-29T10:11:13.000000+00:00",
            "clarificationQuestions": [{
                "question": "Why?",
                "answer": "Because"
            }],
            "sellerSelector": 'allSellers',
            "dates": {
                "answers_close": None,
                "application_open_weeks": "2 weeks",
                "closing_date": None,
                "closing_time": None,
                "published_date": None,
                "questions_close": None,
                "hypothetical": {
                    "answers_close": "2016-10-19T07:00:00+00:00",
                    "application_open_weeks": "2 weeks",
                    "closing_date": "2016-10-20",
                    "closing_time": "2016-10-20T07:00:00+00:00",
                    "published_date": "2016-10-06",
                    "questions_close": "2016-10-13T07:00:00+00:00"
                }
            }
        }
    }

    assert api_stubs.brief(status='live', clarification_questions_closed=True) \
        == {
        "briefs": {
            "id": 1234,
            "title": "I need a thing to do a thing",
            "frameworkFramework": "digital-outcomes-and-specialists",
            "frameworkSlug": "digital-outcomes-and-specialists",
            "frameworkName": "Digital Outcomes and Specialists",
            "lotSlug": "digital-specialists",
            "status": "live",
            "users": [{"active": True,
                       "role": "buyer",
                       "emailAddress": "*****@*****.**",
                       "id": 123,
                       "name": "Buyer User"}],
            "createdAt": "2016-03-29T10:11:12.000000+00:00",
            "updatedAt": "2016-03-29T10:11:13.000000+00:00",
            "publishedAt": "2016-03-29T10:11:14.000000+00:00",
            "applicationsClosedAt": "2016-04-07T00:00:00.000000+00:00",
            "clarificationQuestionsClosedAt": "2016-04-02T00:00:00.000000+00:00",
            "clarificationQuestionsPublishedBy": "2016-04-06T00:00:00.000000+00:00",
            "clarificationQuestionsAreClosed": True,
            "clarificationQuestions": [],
            "sellerSelector": 'allSellers',
            "dates": {
              "answers_close": "2016-10-19T07:00:00+00:00",
              "application_open_weeks": "2 weeks",
              "closing_date": "2016-10-20",
              "closing_time": "2016-10-20T07:00:00+00:00",
              "published_date": "2016-10-06",
              "questions_close": "2016-10-13T07:00:00+00:00"
            }
        }
    }
Пример #23
0
def test_brief():
    assert api_stubs.brief() \
        == {
        "briefs": {
            "id": 1234,
            "title": "I need a thing to do a thing",
            "frameworkSlug": "digital-outcomes-and-specialists",
            "frameworkName": "Digital Outcomes and Specialists",
            'frameworkFramework': 'digital-outcomes-and-specialists',
            "lotSlug": "digital-specialists",
            "status": "draft",
            "users": [{"active": True,
                       "role": "buyer",
                       "emailAddress": "*****@*****.**",
                       "id": 123,
                       "name": "Buyer User"}],
            "createdAt": "2016-03-29T10:11:12.000000+00:00",
            "updatedAt": "2016-03-29T10:11:13.000000+00:00",
            "clarificationQuestions": [],
            "sellerSelector": 'allSellers',
            "dates": {
                "answers_close": None,
                "application_open_weeks": "2 weeks",
                "closing_date": None,
                "closing_time": None,
                "hypothetical": {
                    "answers_close": "2016-10-19T07:00:00+00:00",
                    "application_open_weeks": "2 weeks",
                    "closing_date": "2016-10-20",
                    "closing_time": "2016-10-20T07:00:00+00:00",
                    "published_date": "2016-10-06",
                    "questions_close": "2016-10-13T07:00:00+00:00"
                },
                "published_date": None,
                "questions_close": None
            }
        }
    }

    assert api_stubs.brief(
        status='live',
        framework_slug='a-framework-slug',
        lot_slug='a-lot-slug', user_id=234,
        framework_name='A Framework Name') \
        == {
        "briefs": {
            "id": 1234,
            "title": "I need a thing to do a thing",
            "frameworkSlug": "a-framework-slug",
            "frameworkName": "A Framework Name",
            "frameworkFramework": "a-framework-slug",
            "lotSlug": "a-lot-slug",
            "status": "live",
            "users": [{"active": True,
                       "role": "buyer",
                       "emailAddress": "*****@*****.**",
                       "id": 234,
                       "name": "Buyer User"}],
            "createdAt": "2016-03-29T10:11:12.000000+00:00",
            "updatedAt": "2016-03-29T10:11:13.000000+00:00",
            "publishedAt": "2016-03-29T10:11:14.000000+00:00",
            "applicationsClosedAt": "2016-04-07T00:00:00.000000+00:00",
            "clarificationQuestionsClosedAt": "2016-04-02T00:00:00.000000+00:00",
            "clarificationQuestionsPublishedBy": "2016-04-06T00:00:00.000000+00:00",
            "clarificationQuestionsAreClosed": False,
            "clarificationQuestions": [],
            "sellerSelector": 'allSellers',
            "dates": {
              "answers_close": "2016-10-19T07:00:00+00:00",
              "application_open_weeks": "2 weeks",
              "closing_date": "2016-10-20",
              "closing_time": "2016-10-20T07:00:00+00:00",
              "published_date": "2016-10-06",
              "questions_close": "2016-10-13T07:00:00+00:00"
            }
        }
    }

    assert api_stubs.brief(clarification_questions=[{"question": "Why?", "answer": "Because"}]) \
        == {
        "briefs": {
            "id": 1234,
            "title": "I need a thing to do a thing",
            "frameworkSlug": "digital-outcomes-and-specialists",
            "frameworkFramework": "digital-outcomes-and-specialists",
            "frameworkName": "Digital Outcomes and Specialists",
            "lotSlug": "digital-specialists",
            "status": "draft",
            "users": [{"active": True,
                       "role": "buyer",
                       "emailAddress": "*****@*****.**",
                       "id": 123,
                       "name": "Buyer User"}],
            "createdAt": "2016-03-29T10:11:12.000000+00:00",
            "updatedAt": "2016-03-29T10:11:13.000000+00:00",
            "clarificationQuestions": [{
                "question": "Why?",
                "answer": "Because"
            }],
            "sellerSelector": 'allSellers',
            "dates": {
                "answers_close": None,
                "application_open_weeks": "2 weeks",
                "closing_date": None,
                "closing_time": None,
                "published_date": None,
                "questions_close": None,
                "hypothetical": {
                    "answers_close": "2016-10-19T07:00:00+00:00",
                    "application_open_weeks": "2 weeks",
                    "closing_date": "2016-10-20",
                    "closing_time": "2016-10-20T07:00:00+00:00",
                    "published_date": "2016-10-06",
                    "questions_close": "2016-10-13T07:00:00+00:00"
                }
            }
        }
    }

    assert api_stubs.brief(status='live', clarification_questions_closed=True) \
        == {
        "briefs": {
            "id": 1234,
            "title": "I need a thing to do a thing",
            "frameworkFramework": "digital-outcomes-and-specialists",
            "frameworkSlug": "digital-outcomes-and-specialists",
            "frameworkName": "Digital Outcomes and Specialists",
            "lotSlug": "digital-specialists",
            "status": "live",
            "users": [{"active": True,
                       "role": "buyer",
                       "emailAddress": "*****@*****.**",
                       "id": 123,
                       "name": "Buyer User"}],
            "createdAt": "2016-03-29T10:11:12.000000+00:00",
            "updatedAt": "2016-03-29T10:11:13.000000+00:00",
            "publishedAt": "2016-03-29T10:11:14.000000+00:00",
            "applicationsClosedAt": "2016-04-07T00:00:00.000000+00:00",
            "clarificationQuestionsClosedAt": "2016-04-02T00:00:00.000000+00:00",
            "clarificationQuestionsPublishedBy": "2016-04-06T00:00:00.000000+00:00",
            "clarificationQuestionsAreClosed": True,
            "clarificationQuestions": [],
            "sellerSelector": 'allSellers',
            "dates": {
              "answers_close": "2016-10-19T07:00:00+00:00",
              "application_open_weeks": "2 weeks",
              "closing_date": "2016-10-20",
              "closing_time": "2016-10-20T07:00:00+00:00",
              "published_date": "2016-10-06",
              "questions_close": "2016-10-13T07:00:00+00:00"
            }
        }
    }
def test_brief():
    assert api_stubs.brief() \
        == {
        "briefs": {
            "id": 1234,
            "title": "I need a thing to do a thing",
            "frameworkSlug": "digital-outcomes-and-specialists",
            "frameworkName": "Digital Outcomes and Specialists",
            "lotSlug": "digital-specialists",
            "status": "draft",
            "users": [{"active": True,
                       "role": "buyer",
                       "emailAddress": "*****@*****.**",
                       "id": 123,
                       "name": "Buyer User"}],
            "createdAt": "2016-03-29T10:11:12.000000Z",
            "updatedAt": "2016-03-29T10:11:13.000000Z",
            "clarificationQuestions": [],
        }
    }

    assert api_stubs.brief(
        status='live',
        framework_slug='a-framework-slug',
        lot_slug='a-lot-slug', user_id=234,
        framework_name='A Framework Name') \
        == {
        "briefs": {
            "id": 1234,
            "title": "I need a thing to do a thing",
            "frameworkSlug": "a-framework-slug",
            "frameworkName": "A Framework Name",
            "lotSlug": "a-lot-slug",
            "status": "live",
            "users": [{"active": True,
                       "role": "buyer",
                       "emailAddress": "*****@*****.**",
                       "id": 234,
                       "name": "Buyer User"}],
            "createdAt": "2016-03-29T10:11:12.000000Z",
            "updatedAt": "2016-03-29T10:11:13.000000Z",
            "publishedAt": "2016-03-29T10:11:14.000000Z",
            "applicationsClosedAt": "2016-04-07T00:00:00.000000Z",
            "clarificationQuestionsClosedAt": "2016-04-02T00:00:00.000000Z",
            "clarificationQuestionsAreClosed": False,
            "clarificationQuestions": [],
        }
    }

    assert api_stubs.brief(clarification_questions=[{"question": "Why?", "answer": "Because"}]) \
        == {
        "briefs": {
            "id": 1234,
            "title": "I need a thing to do a thing",
            "frameworkSlug": "digital-outcomes-and-specialists",
            "frameworkName": "Digital Outcomes and Specialists",
            "lotSlug": "digital-specialists",
            "status": "draft",
            "users": [{"active": True,
                       "role": "buyer",
                       "emailAddress": "*****@*****.**",
                       "id": 123,
                       "name": "Buyer User"}],
            "createdAt": "2016-03-29T10:11:12.000000Z",
            "updatedAt": "2016-03-29T10:11:13.000000Z",
            "clarificationQuestions": [{
                "question": "Why?",
                "answer": "Because"
            }],
        }
    }

    assert api_stubs.brief(status='live', clarification_questions_closed=True) \
        == {
        "briefs": {
            "id": 1234,
            "title": "I need a thing to do a thing",
            "frameworkSlug": "digital-outcomes-and-specialists",
            "frameworkName": "Digital Outcomes and Specialists",
            "lotSlug": "digital-specialists",
            "status": "live",
            "users": [{"active": True,
                       "role": "buyer",
                       "emailAddress": "*****@*****.**",
                       "id": 123,
                       "name": "Buyer User"}],
            "createdAt": "2016-03-29T10:11:12.000000Z",
            "updatedAt": "2016-03-29T10:11:13.000000Z",
            "publishedAt": "2016-03-29T10:11:14.000000Z",
            "applicationsClosedAt": "2016-04-07T00:00:00.000000Z",
            "clarificationQuestionsClosedAt": "2016-04-02T00:00:00.000000Z",
            "clarificationQuestionsAreClosed": True,
            "clarificationQuestions": [],
        }
    }
    def setup(self):
        super(TestResponseResultPage, self).setup()

        self.brief = api_stubs.brief(status='live')
        with self.app.test_client():
            self.login()
    def test_q_and_a_session_details_requires_live_brief(self, data_api_client):
        self.login()
        data_api_client.get_brief.return_value = api_stubs.brief(status='expired')

        res = self.client.get('/suppliers/opportunities/1/question-and-answer-session')
        assert res.status_code == 404
Пример #27
0
 def test_brief_can_be_edited(self):
     assert helpers.buyers_helpers.brief_can_be_edited(
         api_stubs.brief(status='draft')['briefs']) is True
     assert helpers.buyers_helpers.brief_can_be_edited(
         api_stubs.brief(status='live')['briefs']) is False
    def test_q_and_a_session_details_requires_live_brief(self, data_api_client):
        self.login(application_id=1)
        data_api_client.get_brief.return_value = api_stubs.brief(status='expired')

        res = self.client.get(self.url_for('main.question_and_answer_session', brief_id=1))
        assert res.status_code == 404
Пример #29
0
 def test_is_brief_associated_with_user(self):
     brief = api_stubs.brief(user_id=123)['briefs']
     assert buyers_helpers.is_brief_associated_with_user(brief, 123) is True
     assert buyers_helpers.is_brief_associated_with_user(brief,
                                                         234) is False
    def test_clarification_question_form_requires_questions_to_be_open(self, data_api_client):
        self.login(application_id=1)
        data_api_client.get_brief.return_value = api_stubs.brief(status='live', clarification_questions_closed=True)

        res = self.client.get(self.url_for('main.ask_brief_clarification_question', brief_id=1))
        assert res.status_code == 400
    def test_clarification_question_form_requires_live_brief(self, data_api_client):
        self.login(application_id=1)
        data_api_client.get_brief.return_value = api_stubs.brief(status='expired')

        res = self.client.get(self.url_for('main.ask_brief_clarification_question', brief_id=1))
        assert res.status_code == 404
Пример #32
0
    def test_clarification_question_form(self, data_api_client):
        self.login()
        data_api_client.get_brief.return_value = api_stubs.brief(status='live')

        res = self.client.get('/suppliers/opportunities/1/ask-a-question')
        assert res.status_code == 200
    def test_q_and_a_session_details_requires_questions_to_be_open(self, data_api_client):
        self.login()
        data_api_client.get_brief.return_value = api_stubs.brief(status='live', clarification_questions_closed=True)

        res = self.client.get('/suppliers/opportunities/1/question-and-answer-session')
        assert res.status_code == 404
Пример #34
0
    def setup(self):
        super(TestResponseResultPage, self).setup()

        self.brief = api_stubs.brief(status='live')
        with self.app.test_client():
            self.login()
    def setup(self):
        super(TestBriefQuestionAndAnswerSession, self).setup()

        self.brief = api_stubs.brief(status='live', lot_slug='digital-specialists')
        self.brief['briefs']['essentialRequirements'] = ['Essential one', 'Essential two', 'Essential three']
        self.brief['briefs']['niceToHaveRequirements'] = ['Nice one', 'Top one', 'Get sorted']
        self.brief['briefs']['dates'] = {}
        self.brief['briefs']['dates']['closing_time'] = '2017-11-23T07:00:00+00:00'
        self.brief['briefs']['questionAndAnswerSessionDetails'] = False

        lots = [api_stubs.lot(slug="digital-specialists", allows_brief=True)]
        self.framework = api_stubs.framework(status="live", slug="digital-outcomes-and-specialists",
                                             clarification_questions_open=False, lots=lots)

        with self.app.test_client():
            self.login(application_id=1)

        self.supplier = {
            'supplier': {
                "supplierCode": 5678,
                "application_id": 9876,
                "frameworks": [
                    {
                        "agreement_details": None,
                        "agreement_returned_at": None,
                        "countersigned_at": None,
                        "declaration": {},
                        "framework_id": 7,
                        "links": {},
                        "on_framework": None,
                        "supplier_code": 5678
                    }
                ],
                "agreed_to_master_agreement": True,
                "domains": {
                    "assessed": [
                        "Agile delivery and Governance",
                        "Cyber security",
                        "User research and Design"
                    ],
                    "legacy": [
                        "Agile delivery and Governance",
                        "Cyber security",
                        "User research and Design"
                    ],
                    "unassessed": []
                },
            }
        }

        self.application = {
            "application": {
                "application_id": 9876,
                "type": "new",
                "status": "approved"
            }
        }

        class CurrentUser(object):
            pass

        self.current_user = CurrentUser()
        self.current_user.application_id = "9876",
        self.current_user.supplier_code = "5678",
        self.current_user.role = "supplier",
        self.current_user.email = "*****@*****.**",
        self.current_user.id = "5678",
Пример #36
0
 def test_brief_is_withdrawn(self):
     assert helpers.buyers_helpers.brief_is_withdrawn(
         api_stubs.brief(status='withdrawn')['briefs']) is True
     assert helpers.buyers_helpers.brief_is_withdrawn(
         api_stubs.brief(status='live')['briefs']) is False
    def setup(self):
        super(TestBriefQuestionAndAnswerSession, self).setup()

        self.brief = api_stubs.brief(status='live',
                                     lot_slug='digital-specialists')
        self.brief['briefs']['essentialRequirements'] = [
            'Essential one', 'Essential two', 'Essential three'
        ]
        self.brief['briefs']['niceToHaveRequirements'] = [
            'Nice one', 'Top one', 'Get sorted'
        ]
        self.brief['briefs']['dates'] = {}
        self.brief['briefs']['dates'][
            'closing_time'] = '2017-11-23T07:00:00+00:00'
        self.brief['briefs']['questionAndAnswerSessionDetails'] = False

        lots = [api_stubs.lot(slug="digital-specialists", allows_brief=True)]
        self.framework = api_stubs.framework(
            status="live",
            slug="digital-outcomes-and-specialists",
            clarification_questions_open=False,
            lots=lots)

        with self.app.test_client():
            self.login(application_id=1)

        self.supplier = {
            'supplier': {
                "supplierCode":
                5678,
                "application_id":
                9876,
                "frameworks": [{
                    "agreement_details": None,
                    "agreement_returned_at": None,
                    "countersigned_at": None,
                    "declaration": {},
                    "framework_id": 7,
                    "links": {},
                    "on_framework": None,
                    "supplier_code": 5678
                }],
                "agreed_to_master_agreement":
                True,
                "domains": {
                    "assessed": [
                        "Agile delivery and Governance", "Cyber security",
                        "User research and Design"
                    ],
                    "legacy": [
                        "Agile delivery and Governance", "Cyber security",
                        "User research and Design"
                    ],
                    "unassessed": []
                },
            }
        }

        self.application = {
            "application": {
                "application_id": 9876,
                "type": "new",
                "status": "approved"
            }
        }

        class CurrentUser(object):
            pass

        self.current_user = CurrentUser()
        self.current_user.application_id = "9876",
        self.current_user.supplier_code = "5678",
        self.current_user.role = "supplier",
        self.current_user.email = "*****@*****.**",
        self.current_user.id = "5678",