def setUp(self): super(OrganizerActivitiesViewTest, self).setUp() # get organizer organizer = self.organizer # create organizer activities today = now() yesterday = today - timedelta(1) self.unpublished_activities = \ ActivityFactory.create_batch(2, organizer=organizer) # Open activities self.opened_activities = \ ActivityFactory.create_batch(2, published=True, organizer=organizer) CalendarFactory.create_batch(size=2, initial_date=now() + timedelta(days=20), enroll_open=True, activity=factory.Iterator( self.opened_activities)) self.closed_activities = \ ActivityFactory.create_batch(2, published=True, organizer=organizer) self.activities = self.organizer.activity_set.all() # set url self.url = reverse('organizers:activities', kwargs={'organizer_pk': organizer.id}) self.autocomplete_url = reverse('organizers:activities_autocomplete', kwargs={'organizer_pk': organizer.id})
def create_calendars(self): self.stdout.write('Creando calendars') calendars = list() for activity in self.activities: quantity = self.get_quantity() calendars.append( CalendarFactory.create_batch( quantity, activity=activity, enroll_open=factory.Faker('boolean'), is_weekend=factory.Faker('boolean'), is_free=factory.Faker('boolean', chance_of_getting_true=20))) return self.flat_list(calendars)