def test_supplier_stub_single_result_response_with_service_counts(self):
     s = SupplierStub()
     resp = s.single_result_response()
     assert resp['suppliers']['service_counts'] == {
         "G-Cloud 9": 109,
         "G-Cloud 8": 108,
         "G-Cloud 7": 107,
         "G-Cloud 6": 106,
         "G-Cloud 5": 105
     }
Пример #2
0
def api(suppliers):
    with mock.patch("dmapiclient.DataAPIClient") as api_mock:
        api_mock.get_interested_suppliers.return_value = {
            "interestedSuppliers": [id for id in suppliers]
        }
        api_mock.get_supplier.side_effect = \
            lambda id: SupplierStub(id=id).single_result_response()
        api_mock.get_supplier_framework_info.side_effect = \
            lambda id, slug: (
                SupplierFrameworkStub(
                    supplier_id=id,
                    framework_slug=slug,
                    on_framework=suppliers[id]["onFramework"],
                    with_declaration=True,
                    declaration_status="complete",
                ).single_result_response()
            )
        api_mock.find_draft_services_iter.side_effect = \
            lambda id, framework: [
                DraftServiceStub(
                    supplier_id=id,
                    framework_slug=framework,
                    status=draft["status"],
                ).response()
                for draft in suppliers[id].get("drafts", [])
            ]
        yield api_mock
class TestSupplierCompanyDetailsComplete:
    @pytest.mark.parametrize('supplier_data_from_api, expected_result', (
        ({}, False),
        ({
            **SupplierStub().response(), 'dunsNumber': None
        }, False),
        ({
            **SupplierStub().response(), 'name': None
        }, False),
        ({
            **SupplierStub().response(), 'companiesHouseNumber': None
        }, False),
        ({
            **SupplierStub().response(), 'contactInformation': [{}]
        }, False),
        (SupplierStub().response(), True),
        ({
            **SupplierStub().response(), 'registrationCountry': 'gb'
        }, True),
        (SupplierStub(other_company_registration_number=12345).response(),
         True),
    ))
    def test_returns_expected_value_for_input(self, supplier_data_from_api,
                                              expected_result):
        assert supplier_company_details_are_complete(
            supplier_data_from_api) is expected_result
    def test_supplier_stub_with_extra_params(self):
        s = SupplierStub(id=123,
                         contact_id=321,
                         other_company_registration_number='4444',
                         company_details_confirmed=False)
        resp = s.response()

        assert resp['id'] == 123
        assert resp['name'] == "My Little Company"
        assert resp['links'] == {'self': 'http://localhost:5000/suppliers/123'}
        assert resp['contactInformation'][0]['links'] == {
            'self':
            'http://localhost:5000/suppliers/123/contact-information/321'
        }
        assert resp['contactInformation'][0]['id'] == 321
        assert resp['companyDetailsConfirmed'] is False
        assert resp['otherCompanyRegistrationNumber'] == '4444'
        assert resp.get('companiesHouseNumber') is None
        assert resp['registrationCountry'] == 'country:NZ'
 def supplier():
     supplier = SupplierStub(
         **{
             "id": 12345,
             "name": "Supplier Name",
             'description': 'Supplier Description',
             'dunsNumber': '999999999',
             'companiesHouseId': 'SC009988',
         }
     ).single_result_response()
     supplier['suppliers']['contactInformation'] = [{
         'id': 1234,
         'contactName': 'contact name',
         'phoneNumber': '099887',
         'email': '*****@*****.**',
         'website': 'http://myweb.com',
     }]
     return supplier
 def test_supplier_stub_defaults(self):
     assert SupplierStub().response() == {
         "companiesHouseNumber":
         "12345678",
         "companyDetailsConfirmed":
         True,
         "contactInformation": [{
             "address1": "123 Fake Road",
             "city": "Madeupolis",
             "contactName": "Mr E Man",
             "email": "*****@*****.**",
             "id": 4321,
             "links": {
                 "self":
                 "http://localhost:5000/suppliers/1234/contact-information/4321"
             },
             "phoneNumber": "01234123123",
             "postcode": "A11 1AA",
             "website": "https://www.mre.company"
         }],
         "description":
         "I'm a supplier.",
         "dunsNumber":
         "123456789",
         "id":
         1234,
         "links": {
             "self": "http://localhost:5000/suppliers/1234"
         },
         "name":
         "My Little Company",
         "organisationSize":
         "micro",
         "registeredName":
         "My Little Registered Company",
         "registrationCountry":
         "country:GB",
         "tradingStatus":
         "limited company",
         "vatNumber":
         "111222333"
     }