Beispiel #1
0
def fix_report(request, sql_session):
  Session.add(EmployeeGroup(n=1, name='admins'))
  Session.add(Employee(n=1,  name='NAME_1',
                       employee_group_n=1, disabled=False))
  # Этот тупой. Нет правильных ответов
  Session.add(Employee(n=2,  name='NAME_2',
                       employee_group_n=1, disabled=False))

  Session.add(Feature(n=1, name='FEATURE_1'))
  Session.add(Feature(n=2, name='FEATURE_2'))

  Session.add(Question(n=1, feature_n=1, txt='QUESTION_1', answer_n=12))
  Session.add(Answer(n=11, question_n=1, txt='ANSWER_11'))
  Session.add(Answer(n=12, question_n=1, txt='ANSWER_12'))

  Session.add(Question(n=2, feature_n=2, txt='QUESTION_2', answer_n=21))
  Session.add(Answer(n=21, question_n=2, txt='ANSWER_21'))
  Session.add(Answer(n=22, question_n=2, txt='ANSWER_22'))

  Session.add(Result(n=11, question_n=1, answer_n=12,
                     is_correct=True, employee_n=1, ddate=date.today()))
  Session.add(Result(n=12, question_n=1, answer_n=11,
                     is_correct=False, employee_n=2, ddate=date.today()))

  Session.add(Result(n=21, question_n=2, answer_n=21,
                     is_correct=True, employee_n=1, ddate=date.today() + timedelta(days=1)))
  Session.add(Result(n=22, question_n=2, answer_n=22,
                     is_correct=False, employee_n=2, ddate=date.today() + timedelta(days=1)))
Beispiel #2
0
def fix_employees(request, sql_session):
  Session.add(EmployeeGroup(n=1, name='admins'))
  Session.add(Right(n=1, employee_group_n=1,
                    section='question', access='edit'))
  Session.add(Employee(n=1, name='NAME_1',
                       password='******', employee_group_n=1, disabled=False))
  Session.add(Employee(n=2, name='NAME_2',
                       password='******', employee_group_n=1, disabled=False))
Beispiel #3
0
def fix_employees_for_plan(request, sql_session):
  Session.add(EmployeeGroup(n=1, name='SELLERS'))
  Session.add(Right(n=1, employee_group_n=1,
                    section='question', access='edit'))
  Session.add(Employee(n=1, name='EMPLOYEE1',
                       password='', employee_group_n=1, disabled=False))
  Session.add(Employee(n=2, name='EMPLOYEE2',
                       password='', employee_group_n=1, disabled=False))
  Session.add(Employee(n=3, name='EMPLOYEE_DISABLED',
                       password='', employee_group_n=1, disabled=True))
Beispiel #4
0
def fix_results(request, sql_session):
  Session.add(EmployeeGroup(n=1, name='admins'))
  Session.add(Employee(n=1,  name='NAME',
                       password='******', employee_group_n=1, disabled=False))

  Session.add(Feature(n=1, name='-'))
  Session.add(Feature(n=2, name='FEATURE1'))
  Session.add(Feature(n=3, name='FEATURE2'))
  # Session.commit()
  # Вопрос 1 к Теме 2
  Session.add(Question(n=21, feature_n=2, txt='CONTENT21', answer_n=211))
  Session.add(Answer(n=211, question_n=21, txt='CONTENT211'))
  Session.add(Answer(n=212, question_n=21, txt='CONTENT212'))
  Session.add(Answer(n=213, question_n=21, txt='CONTENT213'))

  # Вопрос 2 к Теме 2
  Session.add(Question(n=22, feature_n=2, txt='CONTENT22', answer_n=211))
  Session.add(Answer(n=221, question_n=22, txt='CONTENT221'))
  Session.add(Answer(n=222, question_n=22, txt='CONTENT222'))
  Session.add(Answer(n=223, question_n=22, txt='CONTENT223'))

  # Вопрос 1 к Теме 3
  Session.add(Question(n=31, feature_n=3, txt='CONTENT31', answer_n='311'))
  Session.add(Answer(n=311, question_n=31, txt='CONTENT311'))
  Session.add(Answer(n=312, question_n=31, txt='CONTENT312'))
  Session.add(Answer(n=313, question_n=31, txt='CONTENT313'))

  Session.add(Result(n=1, question_n=21, answer_n=211,
                     is_correct=True, employee_n=1))
  Session.add(Result(n=2, question_n=22, answer_n=221,
                     is_correct=False, employee_n=1))
Beispiel #5
0
    def test_generate_question_plan_finished(self):
        """
    Месячный план ВЫПОЛНЕН
    """
        employee = Employee.get(1)
        PlanCtrl.create(employee.n, today.year, today.month, 1, 1)

        question = QuestionCtrl.generate_question(employee.name)
        assert question.n == 0  # question.n=0 пустой вопрос, означает нет вопроса
Beispiel #6
0
    def test_generate_question_day_finish(self):
        """
    План НЕ ВЫПОЛНЕН. Дневной план ВЫПОЛНЕН
    """
        employee = Employee.get(1)
        PlanCtrl.create(employee.n, today.year, today.month, 2, 1)

        question = QuestionCtrl.generate_question(employee.name)
        # print(question)
        assert question.n == 0  # question.n=0 пустой вопрос, означает нет вопроса
Beispiel #7
0
 def create(name, info, password, employee_group_n, department_n):
     params = {
         'name': name,
         'password': password,
         'info': info,
         'employee_group_n': employee_group_n,
         'department_n': department_n
     }
     employee = Employee.create(params)
     return employee
Beispiel #8
0
def fix_for_pivot_create_feature_report(request, sql_session):
  Session.add(EmployeeGroup(n=2, name='SELLERS'))
  Session.add(Right(n=2, employee_group_n=1,
                    section='question', access='edit'))
  Session.add(Employee(n=2, name='EMPLOYEE_1',
                       password='', employee_group_n=2, disabled=False))
  Session.add(Employee(n=3, name='EMPLOYEE_2',
                       password='', employee_group_n=2, disabled=False))

  feature_group_1 = FeatureGroup(n=1, name='GROUP_1', parent_n=1)
  Session.add(feature_group_1)

  Session.add(Feature(n=1, name='FEATURE_11',
                      feature_group=[feature_group_1, ], employee_n=2, ddate=date.today()))
  Session.add(Feature(n=2, name='FEATURE_12',
                      feature_group=[feature_group_1, ], employee_n=2, ddate=date.today() + timedelta(days=1)))
  Session.add(Feature(n=3, name='FEATURE_21',
                      feature_group=[feature_group_1, ], employee_n=3, ddate=date.today()))
  Session.add(Feature(n=4, name='FEATURE_22',
                      feature_group=[feature_group_1, ], employee_n=3, ddate=date.today() + timedelta(days=1)))
Beispiel #9
0
    def test_generate_question_day_not_finish(self):
        """
    План НЕ ВЫПОЛНЕН. Дневной план НЕ ВЫПОЛНЕН
    """
        employee = Employee.get(1)
        PlanCtrl.create(employee.n, today.year, today.month, 2, 3)

        question = QuestionCtrl.generate_question(employee.name)
        # print(question)
        assert question.n != 0  # question.n=0 пустой вопрос, означает нет вопроса
        ANSWERED_QUESTION_N = 21  # номер отвеченного вопроса из фикстуры
        assert question.n != ANSWERED_QUESTION_N
Beispiel #10
0
 def update(n, name, info, password, employee_group_n, department_n):
     params = {
         'name': name,
         'password': password,
         'info': info,
         'employee_group_n': employee_group_n,
         'department_n': department_n
     }
     if len(params['password']) == 0:
         del params['password']
     employee = Employee.update(n, params)
     return employee
Beispiel #11
0
def fix_employees_for_test(request, sql_session):
  Session.add(EmployeeGroup(n=1, name='admins'))
  Session.add(Right(n=1, employee_group_n=1,
                    section='employee', access='edit'))
  Session.add(Right(n=3, employee_group_n=1,
                    section='question', access='edit'))
  Session.add(Right(n=4, employee_group_n=1,
                    section='answer', access='edit'))
  Session.add(Right(n=5, employee_group_n=1,
                    section='result', access='edit'))
  Session.add(Right(n=6, employee_group_n=1,
                    section='feature', access='edit'))
  Session.add(Right(n=7, employee_group_n=1,
                    section='department', access='edit'))
  Session.add(Right(n=8, employee_group_n=1,
                    section='plan', access='edit'))
  # Session.add(Employee(n=1,  name='NAME', password=crypt(
  #     'password', 'secret service'), employee_group_n=1))
  Session.add(Employee(n=1,  name='NAME',
                       password='******', employee_group_n=1))
Beispiel #12
0
def fix_disabled_employees(request, sql_session):
  Session.add(EmployeeGroup(n=1, name='admins'))
  Session.add(Employee(n=1,  name='NAME',
                       password='******', employee_group_n=1, disabled=True))
Beispiel #13
0
 def test_repeat_question(self):
     employee = Employee.get(1)
     question = QuestionCtrl.get_repeat(employee)
     assert question.n == 31
Beispiel #14
0
 def test_already_answered(self):
     today = date.today()
     employee = Employee.get(1)
     qty_answered = ResultCtrl.count_answered(employee, today.year,
                                              today.month)
     assert qty_answered == 2
Beispiel #15
0
 def test_model_sets_n_automatically(self):
     employee = Employee(name='name_employee')
     Session.add(employee)
     Session.flush()
     assert employee.n is not None
     assert employee.name == 'name_employee'