Skip to content

Commit

Permalink
Testing volunteer app (#736)
Browse files Browse the repository at this point in the history
* Testing volunteer app

* Add docstrings to tests
  • Loading branch information
Monal5031 authored and anjali-dhanuka committed Jul 15, 2018
1 parent 70e1450 commit d1f77a5
Show file tree
Hide file tree
Showing 14 changed files with 985 additions and 558 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ env:
- MOZ_HEADLESS=1

addons:
firefox: "55.0"
firefox: "60.0"

python:
- "3.6.5"
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Django == 1.11.0
docopt == 0.6.2
flake8 == 3.4.1
psycopg2 == 2.7.3
PyPDF2 == 1.26.0
PyYAML == 3.11
requests == 2.7.0
phonenumbers == 8.8.8
Expand Down
2 changes: 1 addition & 1 deletion vms/pom/locators/volunteerProfilePageLocators.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ class VolunteerProfilePageLocators(object):
RESUME_FILE = '//input[@name = "resume_file"]'
DOWNLOAD_RESUME = './/*[@id="collapseResumeFile"]/div/form/button'
EDIT_PROFILE_TEXT = 'Edit Profile'
INVALID_FORMAT_MESSAGE = 'html/body/div[2]/div[2]/form/fieldset/div[13]/div/p/strong'
INVALID_FORMAT_MESSAGE = '//fieldset[1]/div[14]//div[1]//p[1]//strong'
SUBMIT_PATH = '//form[1]'
1 change: 1 addition & 0 deletions vms/pom/pages/basePage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class BasePage(object):
"""Base class to initialize the base page that will be called from all pages"""
ENTER_VALID_VALUE = 'Enter a valid value.'
FIELD_REQUIRED = 'This field is required.'
FIELD_CANNOT_LEFT_BLANK = 'This field cannot be blank.'
START_BEFORE_END = 'Start date must be before the end date'

def __init__(self, driver):
Expand Down
7 changes: 4 additions & 3 deletions vms/pom/pages/volunteerProfilePage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# local Django
from pom.pages.basePage import BasePage
from pom.locators.volunteerProfilePageLocators import VolunteerProfilePageLocators
from pom.locators.volunteerProfilePageLocators import VolunteerProfilePageLocators
from pom.pages.homePage import HomePage


Expand All @@ -12,10 +12,11 @@ def __init__(self, driver):
super(VolunteerProfilePage, self).__init__(driver)

def navigate_to_profile(self):
self.home_page.get_volunteer_profile_link().send_keys("\n")
element = self.home_page.get_volunteer_profile_link()
self.execute_script('arguments[0].click();', element)

def edit_profile(self):
self.find_link(self.elements.EDIT_PROFILE_TEXT).send_keys("\n")
self.find_link(self.elements.EDIT_PROFILE_TEXT).click()

def fill_values(self, new_details):
elements = self.elements
Expand Down
13 changes: 3 additions & 10 deletions vms/pom/pages/volunteerReportPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

# local Django
from pom.pages.basePage import BasePage
from pom.pages.authenticationPage import AuthenticationPage
from pom.locators.volunteerReportPageLocators import VolunteerReportPageLocators
from pom.pages.homePage import HomePage

Expand All @@ -15,25 +14,19 @@ class VolunteerReportPage(BasePage):

def __init__(self, driver):
self.driver = driver
self.authentication_page = AuthenticationPage(self.driver)
self.home_page = HomePage(self.driver)
self.elements = VolunteerReportPageLocators()
super(VolunteerReportPage, self).__init__(driver)

def login_and_navigate_to_report_page(self):
self.authentication_page.server_url = self.live_server_url
self.authentication_page.login({
'username': 'volunteer',
'password': 'volunteer'
})
self.home_page.get_volunteer_report_link().send_keys("\n")
def navigate_to_report_page(self):
self.home_page.get_volunteer_report_link().click()

def get_event_job_selectors(self):
select1 = Select(
self.element_by_xpath(self.elements.REPORT_EVENT_SELECTOR))
select2 = Select(
self.element_by_xpath(self.elements.REPORT_JOB_SELECTOR))
return (select1, select2)
return select1, select2

def fill_report_form(self, dates):
self.element_by_xpath(self.elements.REPORT_START_DATE).clear()
Expand Down
11 changes: 8 additions & 3 deletions vms/pom/pages/volunteerSearchPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@
from pom.pages.basePage import BasePage

# local Django
from pom.locators.volunteerSearchPageLocators import VolunteerSearchPageLocators
from pom.locators.volunteerSearchPageLocators import VolunteerSearchPageLocators
from pom.pages.authenticationPage import AuthenticationPage
from pom.pageUrls import PageUrls


class VolunteerSearchPage(BasePage):

volunteer_search_page = PageUrls.volunteer_search_page
live_server_url = ''

def __init__(self, driver):
self.driver = driver
self.authentication_page = AuthenticationPage(self.driver)
self.elements = VolunteerSearchPageLocators()
super(VolunteerSearchPage, self).__init__(driver)

def navigate_to_volunteer_search_page(self):
self.get_page(self.live_server_url, self.volunteer_search_page)

def submit_form(self):
self.element_by_class_name(self.elements.SUBMIT_PATH).click()

Expand All @@ -41,7 +45,7 @@ def search_country_field(self, search_text):
self.send_to_field(self.elements.COUNTRY_FIELD, search_text)

def search_organization_field(self, search_text):
self.send_to_field(self.elements.ORG_FIELD, search_text)
self.element_by_id('select').send_keys(search_text)

def get_help_block(self):
return self.element_by_class_name(self.elements.HELP_BLOCK)
Expand All @@ -50,7 +54,8 @@ def get_search_results(self):
search_results = self.element_by_xpath(self.elements.RESULT_BODY)
return search_results

def get_results_list(self, search_results):
@staticmethod
def get_results_list(search_results):

result = []
for tr in search_results.find_elements_by_tag_name('tr'):
Expand Down
201 changes: 101 additions & 100 deletions vms/volunteer/models.py
Original file line number Diff line number Diff line change
@@ -1,100 +1,101 @@
# Django
from django.contrib.auth.models import User
from django.core.validators import (RegexValidator, MaxValueValidator,
MinValueValidator)
from django.db import models

# local Django
from organization.models import Organization


class Volunteer(models.Model):
id = models.AutoField(primary_key=True)
first_name = models.CharField(
max_length=30,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(\s)|(\-)]+$', ),
],
)
last_name = models.CharField(
max_length=30,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(\s)|(\-)]+$', ),
],
)
address = models.CharField(
max_length=75,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(0-9)|(\s)|(\-)|(\.)|(,)|(\:)]+$', ),
],
)
city = models.CharField(
max_length=75,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(\s)|(\-)]+$', ),
],
)
state = models.CharField(
max_length=50,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(\s)|(\-)]+$', ),
],
)
country = models.CharField(
max_length=75,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(\s)|(\-)]+$', ),
],
)
phone_number = models.CharField(
max_length=20,
validators=[
RegexValidator(
r'^\s*(?:\+?(\d{1,3}))?([-. (]*(\d{3})[-. )]*)?((\d{3})[-. ]*(\d{2,4})(?:[-.x ]*(\d+))?)\s*$',
message="Please enter a valid phone number",
),
],
)
unlisted_organization = models.CharField(
blank=True,
max_length=100,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(0-9)|(\s)|(\-)|(:)]+$', ),
],
)
# Organization to Volunteer is a one-to-many relationship
organization = models.ForeignKey(Organization, null=True)
# EmailField automatically checks if email address is a valid format
email = models.EmailField(max_length=45, unique=True)
websites = models.TextField(
blank=True,
validators=[
RegexValidator(
r'^(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9]\.[^\s]{2,})+$',
),
],
)
description = models.TextField(
blank=True,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(0-9)|(\s)|(\.)|(,)|(\-)|(!)]+$', ),
],
)
resume = models.TextField(
blank=True,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(0-9)|(\s)|(\.)|(,)|(\-)|(!)]+$', ),
],
)
# all resumes are stored in /srv/vms/resume/
resume_file = models.FileField(
upload_to='vms/resume/', max_length=75, blank=True)
reminder_days = models.IntegerField(
default=1,
validators=[MaxValueValidator(50),
MinValueValidator(1)],
blank=True)

user = models.OneToOneField(User)
def __str__(self):
return '{0} {1}'.format(self.first_name, self.last_name)
# Django
from django.contrib.auth.models import User
from django.core.validators import (RegexValidator, MaxValueValidator,
MinValueValidator)
from django.db import models

# local Django
from organization.models import Organization


class Volunteer(models.Model):
id = models.AutoField(primary_key=True)
first_name = models.CharField(
max_length=30,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(\s)|(\-)]+$', ),
],
)
last_name = models.CharField(
max_length=30,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(\s)|(\-)]+$', ),
],
)
address = models.CharField(
max_length=75,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(0-9)|(\s)|(\-)|(\.)|(,)|(\:)]+$', ),
],
)
city = models.CharField(
max_length=75,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(\s)|(\-)]+$', ),
],
)
state = models.CharField(
max_length=50,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(\s)|(\-)]+$', ),
],
)
country = models.CharField(
max_length=75,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(\s)|(\-)]+$', ),
],
)
phone_number = models.CharField(
max_length=20,
validators=[
RegexValidator(
r'^\s*(?:\+?(\d{1,3}))?([-. (]*(\d{3})[-. )]*)?((\d{3})[-. ]*(\d{2,4})(?:[-.x ]*(\d+))?)\s*$',
message="Please enter a valid phone number",
),
],
)
unlisted_organization = models.CharField(
blank=True,
max_length=100,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(0-9)|(\s)|(\-)|(:)]+$', ),
],
)
# Organization to Volunteer is a one-to-many relationship
organization = models.ForeignKey(Organization, null=True)
# EmailField automatically checks if email address is a valid format
email = models.EmailField(max_length=45, unique=True)
websites = models.TextField(
blank=True,
validators=[
RegexValidator(
r'^(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9]\.[^\s]{2,})+$',
),
],
)
description = models.TextField(
blank=True,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(0-9)|(\s)|(\.)|(,)|(\-)|(!)]+$', ),
],
)
resume = models.TextField(
blank=True,
validators=[
RegexValidator(r'^[(A-Z)|(a-z)|(0-9)|(\s)|(\.)|(,)|(\-)|(!)]+$', ),
],
)
# all resumes are stored in /srv/vms/resume/
resume_file = models.FileField(
upload_to='vms/resume/', max_length=75, blank=True)
reminder_days = models.IntegerField(
default=1,
validators=[MaxValueValidator(50),
MinValueValidator(1)],
blank=True)

user = models.OneToOneField(User)

def __str__(self):
return '{0} {1}'.format(self.first_name, self.last_name)
Loading

0 comments on commit d1f77a5

Please sign in to comment.