def test_brief_response_stub_default_values(self):
     assert BriefResponseStub().response() == {
         "availability": "25/01/2017",
         "brief": {
             "id": 1234,
             "title": "I need a thing to do a thing",
             "status": "live",
             "applicationsClosedAt": "2016-11-22T11:22:33.444444Z",
             "framework": {
                 "family": "digital-outcomes-and-specialists",
                 "name": "Digital Outcomes and Specialists 3",
                 "slug": "digital-outcomes-and-specialists-3",
                 "status": "live"
             }
         },
         "briefId": 1234,
         "createdAt": "2016-11-01T11:22:33.444444Z",
         "essentialRequirements": [],
         "essentialRequirementsMet": True,
         "id": 54321,
         "links": {
             "brief": "http://*****:*****@example.com",
         "submittedAt": "2016-11-21T12:00:01.000000Z",
         "status": "submitted",
         "supplierId": 1234,
         "supplierName": "My Little Company",
         "supplierOrganisationSize": "micro",
     }
Ejemplo n.º 2
0
    def test_get_brief_data(self):
        client = mock.Mock(spec=DataAPIClient)
        client.find_briefs_iter.return_value = [example_brief]
        client.find_brief_responses_iter.return_value = [
            example_winning_brief_response,
            BriefResponseStub().response()
        ]

        logger = mock.Mock()

        rows = get_brief_data(client, logger)

        for row in rows:
            assert isinstance(row, OrderedDict)

        assert rows == [
            OrderedDict((
                ("ID", 12345),
                ("Opportunity", "My Brilliant Brief"),
                (
                    "Link",
                    "https://www.digitalmarketplace.service.gov.uk/digital-outcomes-and-specialists/opportunities/12345"
                ),
                ("Framework", "digital-outcomes-and-specialists-3"),
                ("Category", "digital-specialists"),
                ("Specialist", "technicalArchitect"),
                ("Organisation Name", "HM Dept of Doing Stuff"),
                ("Buyer Domain", "example.gov.uk"),
                ("Location Of The Work", "London"),
                ("Published At", "2019-01-01"),
                ("Open For", "2 weeks"),
                ("Expected Contract Length", "6 months"),
                ("Applications from SMEs", 2),
                ("Applications from Large Organisations", 0),
                ("Total Organisations", 2),
                ("Status", "awarded"),
                ("Winning supplier", "Foo Inc"),
                ("Size of supplier", "small"),
                ("Contract amount", "2345678"),
                ("Contract start date", "2019-06-02"),
                ("Clarification questions", 1),
            ))
        ]

        assert client.find_briefs_iter.call_args_list == [
            mock.call(status="closed,awarded,unsuccessful,cancelled", with_users=True,
                      with_clarification_questions=True)
        ]
        assert client.find_brief_responses_iter.call_args_list == [
            mock.call(brief_id=12345)
        ]
        assert logger.info.call_args_list == [
            mock.call('Fetching closed briefs from API'),
            mock.call('Fetching brief responses for Brief ID 12345')
        ]
Ejemplo n.º 3
0
    def test_get_brief_data_with_buyer_user_details(self):
        client = mock.Mock(spec=DataAPIClient)
        client.find_briefs_iter.return_value = [example_brief]
        client.find_brief_responses_iter.return_value = [
            example_winning_brief_response,
            BriefResponseStub().response()
        ]

        logger = mock.Mock()

        row = get_brief_data(client, logger, include_buyer_user_details=True)[0]

        assert list(row.keys())[-3:] == [
            "Buyer user name", "Buyer email address", "Buyer phone number"
        ]

        assert row["Buyer user name"] == "My Name"
        assert row["Buyer email address"] == "*****@*****.**"
        assert row["Buyer phone number"] == "07700 900461"
Ejemplo n.º 4
0
    def data_api_client(self):
        data_api_client = mock.Mock(spec=DataAPIClient)

        data_api_client.find_frameworks.return_value = {
            "frameworks": [
                FrameworkStub(
                    status="live",
                    slug="digital-outcomes-and-specialists-3",
                    family="digital-outcomes-and-specialists"
                ).response(),
            ]
        }

        data_api_client.find_briefs_iter.return_value = [example_brief]
        data_api_client.find_brief_responses_iter.return_value = [
            example_winning_brief_response,
            BriefResponseStub().response()
        ]

        return data_api_client
    def test_brief_response_stub_extra_kwargs(self):
        br_stub = BriefResponseStub(
            framework_slug="digital-outcomes-and-specialist-3",
            supplier_id=555,
            brief_id=666,
            id=777,
        ).response()

        assert br_stub["brief"]["framework"][
            "slug"] == "digital-outcomes-and-specialist-3"
        assert br_stub["supplierId"] == 555
        assert br_stub["links"][
            "supplier"] == "http://localhost:5000/supplier/555"
        assert br_stub["briefId"] == 666
        assert br_stub["links"]["brief"] == "http://localhost:5000/brief/666"
        assert br_stub['brief']['id'] == 666
        assert br_stub["id"] == 777
        assert br_stub["links"][
            "self"] == "http://localhost:5000/brief-response/777"

        for snakecase_kwarg in ['framework_slug', 'supplier_id', 'brief_id']:
            assert snakecase_kwarg not in br_stub
 def test_brief_response_with_brief_kwarg_takes_precedence_over_brief_id(
         self):
     br_stub = BriefResponseStub(brief={'id': 456}, brief_id=789).response()
     assert br_stub['briefId'] == 456
     assert br_stub["links"]["brief"] == "http://localhost:5000/brief/456"
 def test_brief_response_awarded_status_adds_details(self):
     br_stub = BriefResponseStub(status='awarded').response()
     assert br_stub["awardDetails"] == {
         "awardedContractStartDate": "2017-03-01",
         "awardedContractValue": "10000"
     }
 def test_brief_response_pending_awarded_status_adds_details(self):
     br_stub = BriefResponseStub(status='pending-awarded').response()
     assert br_stub["awardDetails"] == {"pending": True}