def supplier_framework(request, app, supplier, live_example_framework):
    with app.app_context():
        sf = SupplierFramework(supplier_id=supplier['id'],
                               framework_id=live_example_framework['id'],
                               **request.param)
        db.session.add(sf)
        db.session.commit()

        return sf.serialize()
def supplier_framework(request, app, supplier, live_example_framework):
    with app.app_context():
        sf = SupplierFramework(
            supplier_id=supplier['id'],
            framework_id=live_example_framework['id'],
            **request.param
        )
        db.session.add(sf)
        db.session.commit()

        return sf.serialize()
Esempio n. 3
0
    def test_whitespace_values_are_stripped_from_declaration(self):
        supplier_framework = SupplierFramework()
        supplier_framework.declaration = {
            'foo': ' bar ',
            'bar': '',
            'other': ' '
        }

        assert supplier_framework.declaration == {
            'foo': 'bar',
            'bar': '',
            'other': ''
        }
def suppliers(app, request):
    params = request.param if hasattr(request, 'param') else {}
    framework_slug = params[
        'framework_slug'] if 'framework_slug' in params else 'digital-marketplace'
    with app.app_context():
        framework = Framework.query.filter(
            Framework.slug == framework_slug).first()
        for i in range(1, 6):
            db.session.add(
                Supplier(
                    abn=i,
                    code=(i),
                    name='Test Supplier{}'.format(i),
                    contacts=[Contact(name='auth rep', email='*****@*****.**')],
                    data={
                        'contact_email': 'test{}@supplier.com'.format(i),
                        'contact_phone': '123'
                    }))

            db.session.flush()

            db.session.add(
                SupplierFramework(supplier_code=i, framework_id=framework.id))

        db.session.commit()
        yield Supplier.query.all()
Esempio n. 5
0
 def register_g7_interest(self, num):
     self.setup_dummy_suppliers(num)
     with self.app.app_context():
         for supplier_id in range(num):
             db.session.add(
                 SupplierFramework(framework_id=4, supplier_id=supplier_id))
         db.session.commit()
def _supplierframework_fixture_inner(request, app, sf_kwargs=None):
    """
        if @sf_kwargs is a callable, it will be called with each supplier, framework combination as arguments to
        generate the kwargs for each SupplierFramework. a returned value of None will prevent that SupplierFramework
        being created.
    """
    sf_kwargs = sf_kwargs or {}
    supplier_framework_id_pairs = set()
    with app.app_context():
        for supplier, framework in product(Supplier.query.all(), Framework.query.all()):
            kwargs = sf_kwargs(supplier, framework) if callable(sf_kwargs) else sf_kwargs
            if kwargs is not None:
                supplier_framework = SupplierFramework(
                    supplier=supplier,
                    framework=framework,
                    **kwargs
                )
                supplier_framework_id_pairs.add((supplier.supplier_id, framework.id,))
                db.session.add(supplier_framework)

        db.session.commit()

    def teardown():
        with app.app_context():
            for supplier_id, framework_id in supplier_framework_id_pairs:
                SupplierFramework.query.filter(
                    SupplierFramework.supplier_id == supplier_id,
                    SupplierFramework.framework_id == framework_id,
                ).delete()
            db.session.commit()

    request.addfinalizer(teardown)
    def test_list_brief_responses_by_one_framework_slug(
            self, live_dos2_framework):
        supplier_framework = SupplierFramework(
            supplier_id=0, framework_id=live_dos2_framework["id"])
        dos2_brief = Brief(data=example_listings.brief_data().example(),
                           status='live',
                           framework_id=live_dos2_framework["id"],
                           lot=Lot.query.get(6))

        db.session.add_all([dos2_brief, supplier_framework])
        db.session.commit()

        dos2_brief_id = dos2_brief.id

        for i in range(3):
            self.setup_dummy_brief_response(brief_id=self.brief_id,
                                            supplier_id=0)
            self.setup_dummy_brief_response(brief_id=dos2_brief_id,
                                            supplier_id=0)

        res = self.list_brief_responses(
            framework='digital-outcomes-and-specialists-2')
        data = json.loads(res.get_data(as_text=True))

        assert res.status_code == 200
        assert len(data['briefResponses']) == 3
        assert all(br['brief']['framework']['slug'] ==
                   "digital-outcomes-and-specialists-2"
                   for br in data['briefResponses'])
        assert 'self' in data['links']
Esempio n. 8
0
 def register_framework_interest(self, framework_id, supplier_ids):
     with self.app.app_context():
         for supplier_id in supplier_ids:
             db.session.add(
                 SupplierFramework(framework_id=framework_id,
                                   supplier_id=supplier_id,
                                   declaration={}))
         db.session.commit()
Esempio n. 9
0
    def create_selection_answers(self, framework_id, supplier_ids, status=None):
        with self.app.app_context():
            for supplier_id in supplier_ids:
                db.session.add(
                    SupplierFramework(
                        framework_id=framework_id,
                        supplier_id=supplier_id,
                        declaration={'status': status},
                    )
                )

            db.session.commit()
def recruiter(app, request, users):
    with app.app_context():
        supplier = Supplier(abn=123,
                            code=456,
                            name='Test Recruiter',
                            data={'recruiter': 'yes'})

        db.session.add(supplier)
        framework = db.session.query(Framework).filter(
            Framework.slug == 'digital-marketplace').first()
        db.session.add(
            SupplierFramework(framework_id=framework.id,
                              supplier_code=supplier.code))

        db.session.commit()
        yield db.session.query(Supplier).filter(Supplier.code == 456).first()
    def setup(self):
        super(BaseBriefResponseTest, self).setup()

        self.supplier_ids = self.setup_dummy_suppliers(2)
        supplier_frameworks = [
            SupplierFramework(supplier_id=supplier_id, framework_id=5)
            for supplier_id in self.supplier_ids
        ]
        brief = Brief(data=example_listings.brief_data().example(),
                      status='live',
                      framework_id=5,
                      lot=Lot.query.get(5))

        service = Service(
            service_id='1234560987654321',
            data={'locations': [brief.data['location']]},
            status='published',
            framework_id=5,
            lot_id=5,
            supplier_id=0,
        )

        specialist_brief = Brief(data=example_listings.brief_data().example(),
                                 status='live',
                                 framework_id=5,
                                 lot=Lot.query.get(6))

        specialist_service = Service(
            service_id='1234560987654322',
            data={
                'developerLocations': [specialist_brief.data['location']],
                'developerPriceMin': "0",
                'developerPriceMax': "1000"
            },
            status='published',
            framework_id=5,
            lot_id=6,
            supplier_id=0,
        )

        db.session.add_all(
            [service, specialist_service, brief, specialist_brief] +
            supplier_frameworks)
        db.session.commit()
        self.brief_id = brief.id
        self.specialist_brief_id = specialist_brief.id
def suppliers(app, request):
    with app.app_context():
        for i in range(1, 6):
            db.session.add(
                Supplier(
                    abn=i,
                    code=(i),
                    name='Test Supplier{}'.format(i),
                    contacts=[Contact(name='auth rep', email='*****@*****.**')],
                    data={
                        'representative': 'auth rep',
                        'phone': '0123456789',
                        'email': '*****@*****.**',
                        'documents': {
                            "liability": {
                                "filename":
                                "1.pdf",
                                "expiry":
                                pendulum.tomorrow().date().to_date_string()
                            },
                            "workers": {
                                "filename":
                                "2.pdf",
                                "expiry":
                                pendulum.tomorrow().date().to_date_string()
                            },
                            "financial": {
                                "filename": "3.pdf"
                            }
                        },
                        'pricing': {
                            "Emerging technologies": {
                                "maxPrice": "1000"
                            },
                            "Support and Operations": {
                                "maxPrice": "100"
                            },
                            "Agile delivery and Governance": {
                                "maxPrice": "1000"
                            },
                            "Data science": {
                                "maxPrice": "100"
                            },
                            "Change, Training and Transformation": {
                                "maxPrice": "1000"
                            },
                            "Training, Learning and Development": {
                                "maxPrice": "1000"
                            },
                            "Strategy and Policy": {
                                "maxPrice": "1000"
                            },
                            "Software engineering and Development": {
                                "maxPrice": "1000"
                            },
                            "User research and Design": {
                                "maxPrice": "1000"
                            },
                            "Recruitment": {
                                "maxPrice": "1000"
                            }
                        }
                    }))

            db.session.flush()

        framework = Framework.query.filter(
            Framework.slug == "digital-marketplace").first()
        db.session.add(
            SupplierFramework(supplier_code=1, framework_id=framework.id))

        db.session.commit()
        yield Supplier.query.all()
    def setup_dummy_suppliers_with_old_and_new_domains(self, n):
        with self.app.app_context():
            framework = Framework.query.filter_by(
                slug='digital-outcomes-and-specialists').first()
            self.set_framework_status(framework.slug, 'open')

            for i in range(1, n + 1):
                if i == 2:
                    ps = PriceSchedule.from_json({
                        'serviceRole': {
                            'category':
                            'Technical Architecture, Development, Ethical Hacking and Web Operations',
                            'role': 'Senior Ethical Hacker'
                        },
                        'hourlyRate': 999,
                        'dailyRate': 9999,
                        'gstIncluded': True
                    })
                    prices = [ps]
                else:
                    prices = []

                NON_MATCHING_STRING = 'aaaaaaaaaaaaaaaaa'

                name = "Supplier {}".format(i - 1)
                summary = "suppliers of supplies" if name != 'Supplier 3' else NON_MATCHING_STRING
                name = name if name != 'Supplier 3' else NON_MATCHING_STRING

                t = pendulum.now('UTC')

                s = Supplier(
                    code=i,
                    name=name,
                    abn='1',
                    description="",
                    summary=summary,
                    data={'seller_type': {
                        'sme': True,
                        'start_up': True
                    }} if i == 2 else {
                        'sme': True,
                        'start_up': False
                    },
                    addresses=[
                        Address(address_line="{} Dummy Street".format(i),
                                suburb="Dummy",
                                state="ZZZ",
                                postal_code="0000",
                                country='Australia')
                    ],
                    contacts=[],
                    references=[],
                    prices=prices,
                    last_update_time=t + pendulum.interval(seconds=(i % 3)))

                if i == 2:
                    s.add_unassessed_domain('Data science')

                if i == 4:
                    s.add_unassessed_domain('Content and Publishing')

                if i == 3:
                    s.add_unassessed_domain('Content and Publishing')
                    s.add_unassessed_domain('Data science')
                    s.update_domain_assessment_status('Data science',
                                                      'assessed')

                p1 = Product(name='zzz {}'.format(i),
                             summary='summary {}'.format(i))
                p2 = Product(name='otherproduct {}'.format(i),
                             summary='othersummary {}'.format(i))

                s.products = [p1, p2]

                sf = SupplierFramework(supplier_code=s.code,
                                       framework_id=framework.id,
                                       declaration={})

                db.session.add(s)
                db.session.add(sf)

            ds = Supplier(
                name=u"Dummy Supplier",
                abn=Supplier.DUMMY_ABN,
                description="",
                summary="",
                addresses=[
                    Address(address_line="{} Dummy Street".format(i),
                            suburb="Dummy",
                            state="ZZZ",
                            postal_code="0000",
                            country='Australia')
                ],
                contacts=[],
                references=[],
                prices=prices,
            )

            ds.add_unassessed_domain('Content and Publishing')
            ds.add_unassessed_domain('Data science')
            ds.update_domain_assessment_status('Data science', 'assessed')

            db.session.add(ds)

            sf = SupplierFramework(supplier_code=ds.code,
                                   framework_id=framework.id,
                                   declaration={})

            db.session.add(sf)
            db.session.commit()
Esempio n. 14
0
    def test_nulls_are_stripped_from_declaration(self):
        supplier_framework = SupplierFramework()
        supplier_framework.declaration = {'foo': 'bar', 'bar': None}

        assert supplier_framework.declaration == {'foo': 'bar'}