# 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/regions/models.py
# class RegionalLead(models.Model):
#     location = models.ForeignKey(Location)
#     leads = models.ManyToManyField(User)
# 
#     class Meta:
#         db_table = 'regional_lead'
#         verbose_name = 'RegionalLead'
#         verbose_name_plural = 'RegionalLeads'
# 
#     def __str__(self):
#         return '{}'.format(self.location)
# 
#     # @property
#     # def get_count_of_leads(self):
#     #     return self.leads.count()
# 
#     # @classmethod
#     # def is_regional_lead(cls, user, location):
#     #     return cls.objects.filter(
#     #         leads=user, location=location).exists()


from datetime import datetime, timedelta
from tests import base
from tests import factories as f
from wye.base.constants import WorkshopStatus, WorkshopLevel
from wye.regions.models import RegionalLead
    # 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=20)
    workshop.status = WorkshopStatus.REQUESTED
    workshop.level = WorkshopLevel.BEGINNER
    workshop.location = org.location
    workshop.save()

    url = base_url + '/workshop/'
    base.login(browser, url, user, password)
    data_check = browser.find_by_text(org.name)
    assert data_check

    browser.visit(url + "?location={}".format(org.location.id))
    data_check = browser.find_by_text(org.name)
    assert data_check

    browser.visit(url + "?location={}".format(org.location.id + 1))
    data_check = browser.find_by_text(org.name)
    assert not data_check


# 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/regions/models.py
# class RegionalLead(models.Model):
#     location = models.ForeignKey(Location)
#     leads = models.ManyToManyField(User)
# 
#     class Meta:
#         db_table = 'regional_lead'
#         verbose_name = 'RegionalLead'
#         verbose_name_plural = 'RegionalLeads'
# 
#     def __str__(self):
#         return '{}'.format(self.location)
# 
#     # @property
#     # def get_count_of_leads(self):
#     #     return self.leads.count()
# 
#     # @classmethod
#     # def is_regional_lead(cls, user, location):
#     #     return cls.objects.filter(
#     #         leads=user, location=location).exists()


# Path: tests/functional/workshop/test_workshop_list.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.regions.models import RegionalLead

    # 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=20)
    workshop.status = WorkshopStatus.REQUESTED
    workshop.level = WorkshopLevel.BEGINNER
    workshop.location = org.location
    workshop.save()

    url = base_url + '/workshop/'
    base.login(browser, url, user, password)
    data_check = browser.find_by_text(org.name)
    assert data_check

    browser.visit(url + "?location={}".format(org.location.id))
    data_check = browser.find_by_text(org.name)
    assert data_check

    browser.visit(url + "?location={}".format(org.location.id + 1))
    data_check = browser.find_by_text(org.name)
    assert not data_check


    browser.visit(url + "?level={}".format(WorkshopStatus.ACCEPTED))