class ActivityTest(UserTest): def setUp(self): UserTest.setUp(self) self.activity = UserActivity( user_id=self.user.id, title="Test Activity", description="Test Description" ) self.activity.add()
class TestUpdateActivity(UserViewTest): def setUp(self): UserViewTest.setUp(self) self.activity = UserActivity( user_id=self.user.id, title="New Activity" ) self.activity.add() def test_should_update_activity_given_valid_activity_input_and_LUHP(self): self.login_user(self.admin_user) activity_input = dict( title="New Activity", description="Test Description" ) with self.client as client: client.post( url_for('user.update_activity', activity_id=self.activity.id), data=activity_input ) self.db.session.rollback() self.assertEqual(self.activity.title, "New Activity") def test_should_not_update_activity_given_invalid_activity_input_and_LUHP(self): self.login_user(self.admin_user) activity_input = dict( title="", description="Test Description" ) with self.client as client: client.post( url_for('user.update_activity', activity_id=self.activity.id), data=activity_input ) self.db.session.rollback() self.assertNotEqual(self.activity.title, "") def test_should_redirect_given_LUHNP(self): self.login_user(self.normal_user) with self.client as client: response = client.get( url_for('user.update_activity', activity_id=self.activity.id) ) self.assertStatus(response, 302)
class UserScheduleTest(UserTest): def setUp(self): UserTest.setUp(self) self.user_production = UserProduction( user_id=self.user.id, concept="Test Production", quantity=10, date=date.today() ) self.user_production.add() user_production2 = UserProduction( user_id=self.user.id, concept="Test Production", quantity=10, date=date.today() + timedelta(days=10) ) user_production2.add() self.user_activity = UserActivity( user_id=self.user.id, title="Test Activity" ) self.user_activity.add() self.order = Order( user_id=self.user.id, title="Test Activity", status="Cancelada", due_date=date.today() ) self.order.add() order2 = Order( user_id=self.user.id, title="Test Activity", status="Pendiente", due_date=date.today() + timedelta(days=10) ) order2.add()