def test_edit_event(self): """Edit event with inactive categories.""" start_form = { 'start_form_0_month': 1, 'start_form_0_day': 25, 'start_form_0_year': 2014, 'start_form_1_hour': 4, 'start_form_1_minute': 1} end_form = { 'end_form_0_month': 1, 'end_form_0_day': 25, 'end_form_0_year': 2015, 'end_form_1_hour': 4, 'end_form_1_minute': 1} owner = UserFactory.create(groups=['Mentor']) active_areas = FunctionalAreaFactory.create_batch(2) inactive_areas = FunctionalAreaFactory.create_batch(2, active=False) event = EventFactory.create(owner=owner, categories=inactive_areas) data = model_to_dict(event) data['categories'] = [x.id for x in active_areas + inactive_areas] data.update(start_form) data.update(end_form) form = EventForm(data=data, editable_owner=False, instance=event) ok_(form.is_valid()) result = form.save() for area in active_areas + inactive_areas: ok_(area in result.categories.all())
def test_edit_event(self): """Edit event with inactive categories.""" start_form = { 'start_form_0_month': 1, 'start_form_0_day': 25, 'start_form_0_year': 2014, 'start_form_1_hour': 4, 'start_form_1_minute': 1} end_form = { 'end_form_0_month': 1, 'end_form_0_day': 25, 'end_form_0_year': 2015, 'end_form_1_hour': 4, 'end_form_1_minute': 1} owner = UserFactory.create(groups=['Mentor']) functional_area = [FunctionalAreaFactory.create()] campaign = [CampaignFactory.create()] event = EventFactory.create(owner=owner, categories=functional_area) data = model_to_dict(event) data['categories'] = functional_area[0].id data['campaign'] = campaign[0].id data.update(start_form) data.update(end_form) form = EventForm(data=data, editable_owner=False, instance=event) ok_(form.is_valid()) result = form.save() ok_(functional_area[0] in result.categories.all())