def setUpClass(cls): setup_logger(LOGS_PATH, LOGS_LEVEL, LOGS_FORMAT) queries.add_user(EXECUTOR) queries.add_user('user_readonly') owners = [ Owner(EXECUTOR, AccessLevels.EDIT.value), Owner('user_readonly', AccessLevels.READONLY.value) ] cls.task_id = queries.add_task(EXECUTOR, 'task_1', 'test_task', 'category_1', datetime(2018, 6, 14, 3), 1, owners=owners) cls.event_id = queries.add_event(EXECUTOR, 'event_1', datetime(2018, 6, 20), datetime(2018, 6, 21), 'test_event', 'category_1', 1, 'Minsk', participants=owners)
def setUpClass(cls): setup_logger(LOGS_PATH, LOGS_LEVEL, LOGS_FORMAT) queries.add_user(EXECUTOR) queries.add_user('user_readonly') queries.add_user('user_2') queries.add_user('user_3') cls.task_1_id = queries.add_task(EXECUTOR, 'task_1', 'test_task') cls.task_2_id = queries.add_task(EXECUTOR, 'task_2', 'test_task') cls.task_3_id = queries.add_task(EXECUTOR, 'task_3', 'test_task') cls.task_4_id = queries.add_task(EXECUTOR, 'task_4', 'test_task') cls.task_5_id = queries.add_task(EXECUTOR, 'task_5', 'test_task') cls.event_1_id = queries.add_event(EXECUTOR, 'event_1', description='test_event') cls.event_2_id = queries.add_event(EXECUTOR, 'event_2', description='test_event') cls.plan_id = queries.add_plan(EXECUTOR, 'plan_1', 'test_plan') cls.reminder_1_id = queries.add_reminder( EXECUTOR, 'test_reminder_1', None, datetime(2018, 6, 15, 13, 45), datetime(2018, 7, 1, 11, 10), timedelta(days=3), [ datetime(2018, 6, 18, 18, 30), datetime(2018, 6, 20, 12) ], timedelta(minutes=30), [0, 1] ) cls.reminder_2_id = queries.add_reminder(EXECUTOR, 'test_reminder_2')
def setUpClass(cls): setup_logger(LOGS_PATH, LOGS_LEVEL, LOGS_FORMAT) queries.add_user(USER_NAME) owners = [Owner(USER_NAME, AccessLevels.EDIT.value)] queries.add_task(USER_NAME, title='test_task_1', category='test', owners=owners) queries.add_task(USER_NAME, title='test_task_2', category='test', owners=owners) queries.add_plan(USER_NAME, 'unique_plan', owners=owners) queries.add_reminder( USER_NAME, description='test_reminder_1', remind_in=timedelta(days=1), interval=timedelta(hours=1), weekdays=[0, 6], datetimes=[datetime(2018, 6, 7, 11), datetime(2018, 6, 8, 13)]) queries.add_reminder( USER_NAME, description='test_reminder_2', remind_in=timedelta(hours=5), interval=timedelta(hours=4), datetimes=[datetime(2018, 6, 7, 19), datetime(2018, 6, 7, 23, 5)]) queries.add_reminder(USER_NAME, description='test_reminder_3', start_remind_from=datetime(2018, 6, 7, 6), stop_remind_in=datetime(2018, 6, 15), interval=timedelta(hours=1), weekdays=[3, 4, 5], datetimes=[ datetime(2018, 6, 7, 10, 15), datetime(2018, 6, 7, 18, 50), datetime(2018, 6, 9, 10), datetime(2018, 6, 10, 15) ]) queries.add_reminders_to_task( USER_NAME, queries.get_tasks(USER_NAME, 'test_task_1')[0].id, [queries.get_reminders(USER_NAME, 'test_reminder_1')[0].id]) queries.add_reminders_to_task( USER_NAME, queries.get_tasks(USER_NAME, 'test_task_2')[0].id, [queries.get_reminders(USER_NAME, 'test_reminder_2')[0].id])
def setUpClass(cls): setup_logger(LOGS_PATH, LOGS_LEVEL, LOGS_FORMAT) queries.add_user(EXECUTOR) queries.add_user('user_2') owners = [ Owner(EXECUTOR, AccessLevels.EDIT.value), Owner('user_2', AccessLevels.EDIT.value) ] cls.task_1_id = queries.add_task(EXECUTOR, 'task_1', 'test_task', 'category_1', datetime(2018, 6, 14, 3), 1, owners=owners) queries.add_task(EXECUTOR, 'task_2', 'test_task', 'category_2', datetime(2018, 6, 14, 10), 1, owners=owners) queries.add_task(EXECUTOR, 'task_3', 'test_task', 'category_1', datetime(2018, 6, 20, 3), 3, owners=owners) queries.add_task(EXECUTOR, 'task_4', 'test_task', 'category_2', datetime(2018, 6, 17, 3), 1, owners=owners) queries.add_task(EXECUTOR, 'task_5', 'test_task', 'category_1', datetime(2018, 6, 24, 3), 1, owners=owners)
def signup(request): if request.user.is_authenticated: return redirect('/tasks/') args = {} args['form'] = SignupForm() if request.POST: user_form = SignupForm(request.POST) if user_form.is_valid(): user_form.save() username = user_form.cleaned_data['username'] password = user_form.cleaned_data['password2'] user = auth.authenticate(username=username, password=password) auth.login(request, user) queries.add_user(username) return redirect('/') else: args['form'] = user_form return render(request, 'accounts/signup.html', args)
def test_add_reminder(self): description = 'test_reminder' start_remind_from = datetime(2018, 6, 15, 9, 15) stop_remind_in = datetime(2018, 6, 20, 23, 45) remind_in = timedelta(days=1) datetimes = [datetime(2018, 6, 15, 15), datetime(2018, 6, 17, 1, 10)] interval = timedelta(minutes=20) weekdays = [2, 4, 5] queries.add_user('user_1') queries.add_reminder('user_1', description, None, start_remind_from, stop_remind_in, remind_in, datetimes, interval, weekdays) self.assertTrue( Reminder.objects.filter(description=description, start_remind_from=start_remind_from, stop_remind_in=stop_remind_in, remind_in=remind_in, datetimes=datetimes, interval=interval, weekdays=weekdays).exists())
def setUpClass(cls): setup_logger(LOGS_PATH, LOGS_LEVEL, LOGS_FORMAT) queries.add_user(EXECUTOR) queries.add_user('user_readonly') owners = [ Owner(EXECUTOR, AccessLevels.EDIT.value), Owner('user_readonly', AccessLevels.READONLY.value) ] cls.task_id = queries.add_task(EXECUTOR, 'task_1', 'test_task', 'category_1', datetime(2018, 6, 14, 3), 1, owners=owners) cls.event_id = queries.add_event(EXECUTOR, 'event_1', datetime(2018, 6, 20), datetime(2018, 6, 21), 'test_event', 'category_1', 1, 'Minsk', participants=owners) cls.plan_id = queries.add_plan(EXECUTOR, 'plan_1', 'test_plan', 'category_2', owners=owners) cls.reminder_id = queries.add_reminder( EXECUTOR, 'test_reminder', None, datetime(2018, 6, 15, 13, 45), datetime(2018, 7, 1, 11, 10), timedelta(days=3), [datetime(2018, 6, 18, 18, 30), datetime(2018, 6, 20, 12)], timedelta(minutes=30), [0, 1])
def test_add_user(self): user_name = 'user_1' queries.add_user(user_name) self.assertTrue(User.objects.filter(name=user_name).exists())
def add_user(args): user_name = queries.add_user(args.name) print(user_name)