def setUp(self): """Set up each test""" OrganizationFactory.create( name="Flota zjednoczonych sił", address="Psia Wólka" ) self.fake_organization = OrganizationFactory.create()
def setUp(self): OrganizationFactory.create(name="Nazwa organizacji1", ) OrganizationFactory.create() # User is created as a Subfactory of UserProfile self.fake_user_profile = UserProfileFactory.create( user__first_name="Edmund", organizations=Organization.objects.all(), phone_no="22909")
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 test_login(self): user = UserFactory.create(password='******') organization = OrganizationFactory.create() organization.userprofiles = [user.userprofile] organization.save() res = self.client.post(ENDPOINT_URL, { 'username': user.username, 'password': '******' }, format='json') self.assertEqual(res.status_code, 200)
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 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 setUp(self): """ Set up for each test """ self.org = OrganizationFactory.create()