def handle(self, *args, **options): """Populate database with fake objects.""" self.stdout.write(self.style.SUCCESS('Creating 15 organizations')) for _ in tqdm(range(15)): organization = OrganizationFactory.create() UserProfileFactory.create(organizations=(organization, ), ) self.stdout.write(self.style.SUCCESS('Creating 50 offers')) for _ in tqdm(range(50)): OfferFactory.create( organization=random.choice(Organization.objects.all()), image__path=ImageField( from_func=placeimg_com_download(1000, 400, 'any'))) self.stdout.write(self.style.SUCCESS('Creating 150 volunteers')) for _ in tqdm(range(150)): userprofile = UserProfileFactory.create() no_of_offers = random.randrange(10) for offer in random.sample(list(Offer.objects.all()), no_of_offers): offer.volunteers.add(userprofile.user) self.stdout.write( self.style.SUCCESS('Database successfully populated'))
def setUp(self): """Set up test for OfferFactory""" self.fake_user1 = UserFactory.create( first_name="Fake user first_name1", last_name="Fake user last_name1") self.fake_user2 = UserFactory.create( first_name="Fake user first_name2", last_name="Fake user last_name2") self.fake_offer1 = OfferFactory.create(volunteers=User.objects.all()) self.fake_offer2 = OfferFactory.create( title="Jakiś tytuł", description="Zwięzły opis", organization__name="Nazwa odnośnej organizacji") self.fake_offer3 = OfferFactory.create( organization=Organization.objects.last())
def setUp(self): """Set up each test.""" super(TestAuthenticatedUserJoinOffer, self).setUp() self.user = UserFactory.create() self.offer = OfferFactory.create() self.offer.publish() self.client.force_login(self.user)
def handle(self, *args, **options): """Populate database with fake objects.""" # create 5 organizations: for _ in range(5): organization = OrganizationFactory.create() UserProfileFactory.create(organizations=(organization, ), ) # create 50 offers: for _ in range(50): OfferFactory.create( organization=random.choice(Organization.objects.all())) # create 150 volunteers: for _ in range(150): userprofile = UserProfileFactory.create() no_of_offers = random.randrange(10) for offer in random.sample(list(Offer.objects.all()), no_of_offers): offer.volunteers.add(userprofile.user) self.stdout.write( self.style.SUCCESS('Database successfully populated'))
def handle(self, *args, **options): """Populate database with fake objects.""" # create 5 organizations for organization in range(0, 5): OrganizationFactory.create() # create admin-user UserProfileFactory.create(is_administrator=True) # create 15 volunteers for volunteer in range(0, 14): UserProfileFactory.create( organizations=self.create_list_of_objects('Organization', 3), is_administrator=False) # create 50 offers for offer in range(0, 50): OfferFactory.create( organization=self.create_list_of_objects('Organization', 1)[0], volunteers=self.create_list_of_objects('User', 3)) self.stdout.write( self.style.SUCCESS('Database successfully populated'))
def setUp(self): """ Set up for each test """ self.offer = OfferFactory.create() self.offer.publish()