def setup_dummy_services_including_unpublished(self, n): self.setup_dummy_suppliers(TEST_SUPPLIERS_COUNT) self.setup_dummy_services(n) with self.app.app_context(): # Add extra 'enabled' and 'disabled' services self.setup_dummy_service( service_id=str(n + 2000000001), supplier_id=n % TEST_SUPPLIERS_COUNT, status='disabled') self.setup_dummy_service( service_id=str(n + 2000000002), supplier_id=n % TEST_SUPPLIERS_COUNT, status='enabled') # Add an extra supplier that will have no services db.session.add( Supplier(supplier_id=TEST_SUPPLIERS_COUNT, name=u'Supplier {}' .format(TEST_SUPPLIERS_COUNT)) ) db.session.add( ContactInformation( supplier_id=TEST_SUPPLIERS_COUNT, contact_name=u'Contact for Supplier {}'.format( TEST_SUPPLIERS_COUNT), email=u'{}@contact.com'.format(TEST_SUPPLIERS_COUNT), postcode=u'SW1A 1AA' ) ) db.session.commit()
def setup_dummy_suppliers(self, n): supplier_ids = [] for i in range(n): db.session.add( Supplier( supplier_id=i, registered_name='Registered Supplier Name {}'.format(i), name=u'Supplier {}'.format(i), description='', organisation_size='small', duns_number='{}'.format(100000000 + i), registration_country='country:GB', companies_house_number='{}'.format(12345670 + i), other_company_registration_number='555-222-111' ) ) db.session.add( ContactInformation( supplier_id=i, contact_name=u'Contact for Supplier {}'.format(i), email=u'{}@contact.com'.format(i), postcode=u'SW1A 1AA', address1='7 Gem Lane', city='Cantelot' ) ) supplier_ids.append(i) db.session.commit() return supplier_ids
def setup_additional_dummy_suppliers(self, n, initial): for i in range(1000, n + 1000): db.session.add( Supplier(supplier_id=i, name=u'{} suppliers Ltd {}'.format(initial, i), description='')) db.session.add( ContactInformation( supplier_id=i, contact_name=u'Contact for Supplier {}'.format(i), email=u'{}@contact.com'.format(i), postcode=u'SW1A 1AA')) db.session.commit()
def setup_additional_dummy_suppliers(self, n, initial): with self.app.app_context(): for i in range(1000, n + 1000): db.session.add( Supplier(supplier_id=i, name=u"{} suppliers Ltd {}".format(initial, i), description="", clients=[])) db.session.add( ContactInformation( supplier_id=i, contact_name=u"Contact for Supplier {}".format(i), email=u"{}@contact.com".format(i), postcode=u"SW1A 1AA")) db.session.commit()
def _supplier_fixture_inner(request, app, supplier_kwargs=None, ci_kwargs=None): supplier_kwargs = supplier_kwargs or {} supplier_kwargs = dict( { "name": "Supplier {}".format(supplier_kwargs.get( "supplier_id", "")), "description": "some description", }, **supplier_kwargs) with app.app_context(): supplier = Supplier(**supplier_kwargs) db.session.add(supplier) db.session.flush() ci_kwargs = ci_kwargs or {} ci_kwargs = dict( { "contact_name": "Contact for supplier {}".format(supplier.supplier_id), "email": "{}@contact.com".format(supplier.supplier_id), "postcode": "SW1A 1AA", "supplier_id": supplier.supplier_id, }, **ci_kwargs) contact_information = ContactInformation(**ci_kwargs) db.session.add(contact_information) db.session.commit() supplier_id = supplier.supplier_id contact_information_id = contact_information.id def teardown(): with app.app_context(): ContactInformation.query.filter( ContactInformation.id == contact_information_id).delete() Supplier.query.filter(Supplier.supplier_id == supplier_id).delete() db.session.commit() request.addfinalizer(teardown) return supplier_id
def setup_dummy_suppliers(self, n): supplier_ids = [] for i in range(n): db.session.add( Supplier( supplier_id=i, name=u'Supplier {}'.format(i), description='', organisation_size='small', )) db.session.add( ContactInformation( supplier_id=i, contact_name=u'Contact for Supplier {}'.format(i), email=u'{}@contact.com'.format(i), postcode=u'SW1A 1AA')) supplier_ids.append(i) db.session.commit() return supplier_ids
def setup_dummy_suppliers(self, n): supplier_ids = [] with self.app.app_context(): for i in range(n): db.session.add( Supplier( supplier_id=i, name=u'Supplier {}'.format(i), description='', clients=[] ) ) db.session.add( ContactInformation( supplier_id=i, contact_name=u'Contact for Supplier {}'.format(i), email=u'{}@contact.com'.format(i), postcode=u'SW1A 1AA' ) ) supplier_ids.append(i) db.session.commit() return supplier_ids