# Path: tests/base.py
# def create_user(password):
# def login(browser, url, user, password):
# def login_and_confirm(browser, url, outbox, user, password):
# def workshop_create(browser, url, org, section):
# def profile_poc_create(
#         browser, url, usertype_id,
#         section_id, state_id, location_id):
# def profile_tutor_create(
#         browser, url, usertype_id,
#         section_id, state_id, location_id):
# 
# Path: tests/factories.py
# class Factory(factory.DjangoModelFactory):
#     class Meta:
# class UserTypeFactory(Factory):
#     class Meta:
# class UserFactory(Factory):
#     class Meta:
# class StateFactory(Factory):
#     class Meta:
# class LocationFactory(Factory):
#     class Meta:
# class OrganisationFactory(Factory):
#     class Meta:
# class RegionalLeadFactory(Factory):
#     class Meta:
# class WorkshopSectionFactory(Factory):
#     class Meta:
# class WorkshopFactory(Factory):
#     class Meta:
# class WorkshopRatingValuesFactory(Factory):
#     class Meta:
# def create_usertype(**kwargs):
# def create_user(**kwargs):
# def create_organisation(**kwargs):
# def create_regional_lead(**kwargs):
# def create_workshop(**kwargs):
# def create_workshop_rating(**kwargs):
# def create_workshop_section(**kwargs):
# def create_locaiton(**kwargs):
# def create_state(**kwargs):
# 
# Path: wye/base/constants.py
# class WorkshopStatus:
#     _DRAFT = [1, "Draft"]
#     _REQUESTED = [2, "Workshop Requested"]
#     _ACCEPTED = [3, "Workshop Accepted "]
#     _DECLINED = [4, "Workshop Declined"]
#     _FEEDBACK_PENDING = [5, "FeedBack Pending"]
#     _HOLD = [6, "Workshop On Hold"]
#     _COMPLETED = [7, "Workshop Completed"]
#     _UNABLE_TO_COMPLETE = [8, "Workshop unable to complete"]
# 
# class WorkshopLevel:
#     _BEGINNER = [1, "Beginner"]
#     _INTERMEDIATE = [2, "Intermediate"]
#     _ADVANCE = [2, "Advance"]
# 
# Path: wye/workshops/tasks.py
# @task
# def workshop_reminder(days, intro=None, feedback=None):
#     """
#     send workshop reminder and intro email to all register user
#     :return:
#     """
#     if feedback:
#         today = datetime.datetime.today()
#         if days:
#             workshop_date = today + datetime.timedelta(days=2)
#             workshops = Workshop.objects.filter(expected_date=workshop_date)
# 
#             for workshop in workshops:
#                 context_dict = {
#                     'date': workshop_date,
#                     'workshop_title': workshop.workshop_section.name,
#                 }
#                 email_context = Context(context_dict)
#                 organisation = workshop.requester
#                 for requester in workshop.requester.user.all():
#                     feedback_emails(
#                         organisation, email_context, requester.email)
#                 for presenter in workshop.presenter.all():
#                     feedback_emails(
#                         organisation, email_context, presenter.email)
#     else:
#         workshop_date = datetime.date.today() + datetime.timedelta(days=days)
#         workshops = Workshop.objects.select_related(
#             'workshop_section').filter(
#             expected_date=workshop_date).filter(
#             is_active=True)
# 
#         for workshop in workshops:
#             organisation = workshop.requester
# 
#             context_dict = {
#                 'date': workshop_date,
#                 'workshop_title': workshop.workshop_section.name,
#             }
#             if workshop.get_presenter_list:
#                 context_dict['poc_list'] = workshop.requester.user.all()
#                 context_dict['presenter_list'] = workshop.presenter.all()
# 
#                 if intro:
# 
#                     # Below  loop is to send email individually
#                     email_context = Context(context_dict)
#                     for requester in workshop.requester.user.all():
#                             intro_emails(
#                                 organisation, email_context, requester.email)
#                     for presenter in workshop.presenter.all():
#                             intro_emails(
#                                 organisation, email_context, presenter.email)
#                 else:
#                     context_dict['workshop_title'] = workshop.workshop_section.name
#                     context_dict['workshop_date'] = workshop.expected_date
#                     context_dict['trainer'] = workshop.presenter.all()
#                     context_dict['venue'] = """{} , {}""".format(
#                         workshop.requester.name,
#                         workshop.requester.full_address)
#                     context_dict['organiser'] = workshop.requester.name
#                     email_context = Context(context_dict)
#                     for requester in workshop.requester.user.all():
#                         remainder_email(
#                             organisation, email_context, requester.email)
#                     for presenter in workshop.presenter.all():
#                         remainder_email(
#                             organisation, email_context, presenter.email)
#     return True


from datetime import datetime, timedelta
from tests import base
from tests import factories as f
from wye.base.constants import WorkshopStatus, WorkshopLevel
from wye.workshops.tasks import workshop_reminder
    user = base.create_user(password)
    url = base_url + '/workshop/'
    base.login_and_confirm(browser, url, outbox, user, password)
    user.profile.usertype.clear()
    user.profile.usertype.add(poc_type)
    user.profile.interested_states.add(state)
    user.profile.save()
    user.save()

    # Create org
    location = f.create_locaiton(state=state)
    org = f.create_organisation(location=location)
    org.user.add(user)
    user.profile.interested_locations.add(location)
    user.profile.location = org.location
    user.profile.save()
    org.save()

    # Create workshop
    workshop = f.create_workshop(requester=org)
    workshop.expected_date = datetime.now() + timedelta(days=1)
    workshop.status = WorkshopStatus.REQUESTED
    workshop.level = WorkshopLevel.BEGINNER
    workshop.location = org.location
    workshop.presenter.add(user)
    workshop.save()

    rst = workshop_reminder.apply(args=(1, 1, None)).get()
    assert rst


# Path: tests/base.py
# def create_user(password):
# def login(browser, url, user, password):
# def login_and_confirm(browser, url, outbox, user, password):
# def workshop_create(browser, url, org, section):
# def profile_poc_create(
#         browser, url, usertype_id,
#         section_id, state_id, location_id):
# def profile_tutor_create(
#         browser, url, usertype_id,
#         section_id, state_id, location_id):
# 
# Path: tests/factories.py
# class Factory(factory.DjangoModelFactory):
#     class Meta:
# class UserTypeFactory(Factory):
#     class Meta:
# class UserFactory(Factory):
#     class Meta:
# class StateFactory(Factory):
#     class Meta:
# class LocationFactory(Factory):
#     class Meta:
# class OrganisationFactory(Factory):
#     class Meta:
# class RegionalLeadFactory(Factory):
#     class Meta:
# class WorkshopSectionFactory(Factory):
#     class Meta:
# class WorkshopFactory(Factory):
#     class Meta:
# class WorkshopRatingValuesFactory(Factory):
#     class Meta:
# def create_usertype(**kwargs):
# def create_user(**kwargs):
# def create_organisation(**kwargs):
# def create_regional_lead(**kwargs):
# def create_workshop(**kwargs):
# def create_workshop_rating(**kwargs):
# def create_workshop_section(**kwargs):
# def create_locaiton(**kwargs):
# def create_state(**kwargs):
# 
# Path: wye/base/constants.py
# class WorkshopStatus:
#     _DRAFT = [1, "Draft"]
#     _REQUESTED = [2, "Workshop Requested"]
#     _ACCEPTED = [3, "Workshop Accepted "]
#     _DECLINED = [4, "Workshop Declined"]
#     _FEEDBACK_PENDING = [5, "FeedBack Pending"]
#     _HOLD = [6, "Workshop On Hold"]
#     _COMPLETED = [7, "Workshop Completed"]
#     _UNABLE_TO_COMPLETE = [8, "Workshop unable to complete"]
# 
# class WorkshopLevel:
#     _BEGINNER = [1, "Beginner"]
#     _INTERMEDIATE = [2, "Intermediate"]
#     _ADVANCE = [2, "Advance"]
# 
# Path: wye/workshops/tasks.py
# @task
# def workshop_reminder(days, intro=None, feedback=None):
#     """
#     send workshop reminder and intro email to all register user
#     :return:
#     """
#     if feedback:
#         today = datetime.datetime.today()
#         if days:
#             workshop_date = today + datetime.timedelta(days=2)
#             workshops = Workshop.objects.filter(expected_date=workshop_date)
# 
#             for workshop in workshops:
#                 context_dict = {
#                     'date': workshop_date,
#                     'workshop_title': workshop.workshop_section.name,
#                 }
#                 email_context = Context(context_dict)
#                 organisation = workshop.requester
#                 for requester in workshop.requester.user.all():
#                     feedback_emails(
#                         organisation, email_context, requester.email)
#                 for presenter in workshop.presenter.all():
#                     feedback_emails(
#                         organisation, email_context, presenter.email)
#     else:
#         workshop_date = datetime.date.today() + datetime.timedelta(days=days)
#         workshops = Workshop.objects.select_related(
#             'workshop_section').filter(
#             expected_date=workshop_date).filter(
#             is_active=True)
# 
#         for workshop in workshops:
#             organisation = workshop.requester
# 
#             context_dict = {
#                 'date': workshop_date,
#                 'workshop_title': workshop.workshop_section.name,
#             }
#             if workshop.get_presenter_list:
#                 context_dict['poc_list'] = workshop.requester.user.all()
#                 context_dict['presenter_list'] = workshop.presenter.all()
# 
#                 if intro:
# 
#                     # Below  loop is to send email individually
#                     email_context = Context(context_dict)
#                     for requester in workshop.requester.user.all():
#                             intro_emails(
#                                 organisation, email_context, requester.email)
#                     for presenter in workshop.presenter.all():
#                             intro_emails(
#                                 organisation, email_context, presenter.email)
#                 else:
#                     context_dict['workshop_title'] = workshop.workshop_section.name
#                     context_dict['workshop_date'] = workshop.expected_date
#                     context_dict['trainer'] = workshop.presenter.all()
#                     context_dict['venue'] = """{} , {}""".format(
#                         workshop.requester.name,
#                         workshop.requester.full_address)
#                     context_dict['organiser'] = workshop.requester.name
#                     email_context = Context(context_dict)
#                     for requester in workshop.requester.user.all():
#                         remainder_email(
#                             organisation, email_context, requester.email)
#                     for presenter in workshop.presenter.all():
#                         remainder_email(
#                             organisation, email_context, presenter.email)
#     return True


# Path: tests/functional/workshop/test_workshop_celery_tasks.py
from datetime import datetime, timedelta
from tests import base
from tests import factories as f
from wye.base.constants import WorkshopStatus, WorkshopLevel
from wye.workshops.tasks import workshop_reminder

    user = base.create_user(password)
    url = base_url + '/workshop/'
    base.login_and_confirm(browser, url, outbox, user, password)
    user.profile.usertype.clear()
    user.profile.usertype.add(poc_type)
    user.profile.interested_states.add(state)
    user.profile.save()
    user.save()

    # Create org
    location = f.create_locaiton(state=state)
    org = f.create_organisation(location=location)
    org.user.add(user)
    user.profile.interested_locations.add(location)
    user.profile.location = org.location
    user.profile.save()
    org.save()

    # Create workshop
    workshop = f.create_workshop(requester=org)
    workshop.expected_date = datetime.now() + timedelta(days=1)
    workshop.status = WorkshopStatus.REQUESTED
    workshop.level = WorkshopLevel.BEGINNER
    workshop.location = org.location
    workshop.presenter.add(user)
    workshop.save()

    rst = workshop_reminder.apply(args=(1, 1, None)).get()
    assert rst


    rst = workshop_reminder.apply(args=(1, 0, None)).get()