コード例 #1
0
 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()
コード例 #2
0
    def test_should_not_return_error_given_valid_due_date_str_format(self):
        order = Order(user_id=self.user.id,
                      title="Test Title",
                      description="Test Description",
                      due_date="2021-06-30")
        error = order.validation.validate_due_date()

        self.assertEqual(error, None)
コード例 #3
0
    def test_should_return_error_given_invalid_user_id(self):
        order = Order(user_id=0,
                      title="Test Title",
                      description="Test Description",
                      due_date=date.today())
        error = order.validation.validate_user()

        self.assertNotEqual(error, None)
コード例 #4
0
    def test_should_not_return_error_given_valid_order(self):
        order = Order(user_id=self.user.id,
                      title="Test Title",
                      description="Test Description",
                      due_date=date.today())
        error = order.validation.validate()

        self.assertEqual(error, None)
コード例 #5
0
    def test_should_return_error_given_empty_title(self):
        order = Order(user_id=self.user.id,
                      title="",
                      description="Test Description",
                      due_date=date.today())
        error = order.validation.validate_empty_values()

        self.assertNotEqual(error, None)
コード例 #6
0
    def test_should_return_error_given_invalid_due_date(self):
        order = Order(user_id=self.user.id,
                      title="Test Title",
                      description="Test Description",
                      due_date="invalid date format")
        error = order.validation.validate()

        self.assertNotEqual(error, None)
コード例 #7
0
    def test_should_add_order_given_valid_order(self):
        order = Order(user_id=1,
                      title="Test Title",
                      description="Test Description",
                      due_date=date.today())
        order.request.add()

        self.assertIn(order, self.db.session)
コード例 #8
0
    def test_should_not_add_order_given_invalid_order(self):
        order = Order(user_id=1,
                      title="",
                      description="Test Description",
                      due_date="Invalid date")
        order.request.add()

        self.assertNotIn(order, self.db.session)
コード例 #9
0
 def setUp(self):
     UserScheduleTest.setUp(self)
     self.pending_order = Order(
         user_id=self.user.id,
         title="Test Activity",
         status="Pendiente",
         due_date=date.today()
     )
     self.pending_order.add()
コード例 #10
0
 def setUp(self):
     UserScheduleTest.setUp(self)
     self.finished_order = Order(
         user_id=self.user.id,
         title="Test Activity",
         status="Completada",
         due_date=date.today()
     )
     self.finished_order.add()
コード例 #11
0
ファイル: __init__.py プロジェクト: ChrisPoul/Industrias-EnGo
 def setUp(self):
     Test.setUp(self)
     self.user = User(
         username="******",
         password="******"
     )
     self.user.add()
     self.order = Order(
         user_id=self.user.id,
         title="Test Title",
         description="Test Description",
         due_date=date.today()
     )
     self.order.add()
コード例 #12
0
def assign():
    min_date = datetime.today().strftime("%Y-%m-%d")
    users = [user for user in User.query.all() if not user.is_admin()]
    selected_user = initial_user
    if request.method == "POST":
        user_id = request.form['user_id']
        user = User.query.get(user_id)
        if user is not None:
            selected_user = user
        order = Order(user_id=user_id,
                      title=request.form['title'],
                      description=request.form['description'],
                      due_date=request.form["due_date"])
        error = order.request.add()
        if not error:
            return redirect(url_for('user.profile', id=user_id))
        flash(error)

    return render_template("order/assign.html",
                           order_heads=order_heads,
                           min_date=min_date,
                           selected_user=selected_user,
                           users=users)