Beispiel #1
0
def test_query_workers_name_field(sample_worker, sample_worker_query_form):
    sample_worker_query_form.name.data = sample_worker.name
    workers = query_workers(sample_worker_query_form)
    assert sample_worker in workers

    sample_worker_query_form.name.data = "wrong name"
    workers = query_workers(sample_worker_query_form)
    assert sample_worker not in workers
Beispiel #2
0
def test_query_workers_workplace_field(sample_worker, sample_worker_query_form,
                                       sample_workplace):
    sample_worker_query_form.workplace.data = sample_workplace.name
    workers = query_workers(sample_worker_query_form)
    assert sample_worker not in workers

    sample_workplace.set_workplace(sample_worker)
    workers = query_workers(sample_worker_query_form)
    assert sample_worker in workers

    sample_worker_query_form.workplace.data = "all"
    sample_workplace.workers.remove(sample_worker)
    assert sample_worker.workplace != sample_workplace
    workers = query_workers(sample_worker_query_form)
    assert sample_worker in workers
Beispiel #3
0
def test_query_workers_function_field(sample_worker, sample_worker_query_form,
                                      sample_function):
    sample_worker_query_form.function.data = sample_function.name
    workers = query_workers(sample_worker_query_form)
    assert sample_worker not in workers

    sample_function.set_function(sample_worker)
    workers = query_workers(sample_worker_query_form)
    assert sample_worker in workers

    sample_worker_query_form.function.data = "all"
    sample_function.workers.remove(sample_worker)
    assert sample_worker.function != sample_function
    workers = query_workers(sample_worker_query_form)
    assert sample_worker in workers
Beispiel #4
0
def workers_query():
    """
    Allows to filter workers which user wants to find
    :return: list of workers meeting requirements
    """

    required_role(current_user, "user")

    title = "HR wyszukaj pracownika"

    form = FilterWorkersForm()
    form.workplace.choices = [(str(workplace), str(workplace))
                              for workplace in Workplace.query.all()]
    form.workplace.choices.insert(0, ("all", "wszystkie"))
    form.function.choices = [(str(function), str(function))
                             for function in Function.query.all()]
    form.function.choices.insert(0, ("all", "wszystkie"))
    if form.validate_on_submit():
        workers = workers_utils.query_workers(form)
        return render_template("workers/workers_list.html", workers=workers)

    return render_template("workers/workers_query.html",
                           title=title,
                           form=form)
Beispiel #5
0
def test_query_workers_works_field(sample_worker, sample_worker_query_form):
    sample_worker_query_form.works.data = "False"
    sample_worker.working = False
    workers = query_workers(sample_worker_query_form)
    assert sample_worker in workers
    sample_worker.working = True
    workers = query_workers(sample_worker_query_form)
    assert sample_worker not in workers

    sample_worker_query_form.works.data = "True"
    sample_worker.working = True
    workers = query_workers(sample_worker_query_form)
    assert sample_worker in workers
    sample_worker.working = False
    workers = query_workers(sample_worker_query_form)
    assert sample_worker not in workers

    sample_worker_query_form.works.data = "all"
    sample_worker.working = True
    workers = query_workers(sample_worker_query_form)
    assert sample_worker in workers
    sample_worker.working = False
    workers = query_workers(sample_worker_query_form)
    assert sample_worker in workers