本文整理汇总了Python中volunteer.models.Volunteer类的典型用法代码示例。如果您正苦于以下问题:Python Volunteer类的具体用法?Python Volunteer怎么用?Python Volunteer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Volunteer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_get_volunteer_resume_file_url
def test_get_volunteer_resume_file_url(self):
u1 = User.objects.create_user('John')
v1 = Volunteer(
first_name="John",
last_name="Doe",
address="7 Alpine Street",
city="Maplegrove",
state="Wyoming",
country="USA",
phone_number="23454545",
email="[email protected]",
resume_file="MyResume.pdf",
user=u1
)
v1.save()
# test typical cases
self.assertIsNotNone(get_volunteer_resume_file_url(v1.id))
self.assertEqual(
get_volunteer_resume_file_url(v1.id),
v1.resume_file.url
)
# test non-existant cases
self.assertNotEqual(get_volunteer_resume_file_url(v1.id),
"resumes/DifferentResume.pdf"
)
self.assertNotEqual(get_volunteer_resume_file_url(v1.id),
"resumes/AnotherResume.pdf"
)
开发者ID:ahmedsabie,项目名称:vms,代码行数:33,代码来源:tests.py
示例2: test_get_volunteers_ordered_by_first_name
def test_get_volunteers_ordered_by_first_name(self):
u1 = User.objects.create_user('Yoshi')
u2 = User.objects.create_user('Ashley')
u3 = User.objects.create_user('Zelda')
v1 = Volunteer(
first_name="Yoshi",
last_name="Doe",
address="7 Oak Street",
city="Elmgrove",
state="California",
country="USA",
phone_number="23454545",
email="[email protected]",
user=u1
)
v2 = Volunteer(
first_name="Ashley",
last_name="Doe",
address="7 Alpine Street",
city="Maplegrove",
state="Wyoming",
country="USA",
phone_number="23454545",
email="[email protected]",
user=u2
)
v3 = Volunteer(
id=999,
first_name="Zelda",
last_name="Doe",
address="7 Elm Street",
city="Oakgrove",
state="California",
country="USA",
phone_number="23454545",
email="[email protected]",
user=u3
)
v1.save()
v2.save()
v3.save()
# test typical cases
volunteer_list = get_volunteers_ordered_by_first_name()
self.assertIsNotNone(volunteer_list)
self.assertIn(v1, volunteer_list)
self.assertIn(v2, volunteer_list)
self.assertIn(v3, volunteer_list)
self.assertEqual(len(volunteer_list), 3)
# test if in correct order
self.assertEqual(volunteer_list[0], v2)
self.assertEqual(volunteer_list[1], v1)
self.assertEqual(volunteer_list[2], v3)
开发者ID:ahmedsabie,项目名称:vms,代码行数:59,代码来源:tests.py
示例3: test_get_shifts_with_open_slots
def test_get_shifts_with_open_slots(self):
""" Test get_shifts_with_open_slots(j_id) """
u1 = User.objects.create_user("Yoshi")
v1 = Volunteer(
first_name="Yoshi",
last_name="Turtle",
address="Mario Land",
city="Nintendo Land",
state="Nintendo State",
country="Nintendo Nation",
phone_number="2374983247",
email="[email protected]",
user=u1,
)
v1.save()
e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")
e1.save()
j1 = Job(
name="Software Developer",
start_date="2012-10-22",
end_date="2012-10-23",
description="A software job",
event=e1,
)
j2 = Job(
name="Systems Administrator",
start_date="2012-9-1",
end_date="2012-10-26",
description="A systems administrator job",
event=e1,
)
j1.save()
j2.save()
s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)
s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)
s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)
s1.save()
s2.save()
s3.save()
self.assertIsNotNone(get_shifts_with_open_slots(j1.id))
self.assertIsNotNone(get_shifts_with_open_slots(j2.id))
开发者ID:ahmedsabie,项目名称:vms,代码行数:53,代码来源:tests.py
示例4: test_has_resume_file
def test_has_resume_file(self):
u1 = User.objects.create_user('John')
u2 = User.objects.create_user('James')
u3 = User.objects.create_user('Jane')
v1 = Volunteer(
first_name="John",
last_name="Doe",
address="7 Alpine Street",
city="Maplegrove",
state="Wyoming",
country="USA",
phone_number="23454545",
email="[email protected]",
resume_file="MyResume.pdf",
user=u1
)
v2 = Volunteer(
first_name="James",
last_name="Doe",
address="7 Alpine Street",
city="Maplegrove",
state="Wyoming",
country="USA",
phone_number="23454545",
email="[email protected]",
user=u2
)
v3 = Volunteer(
first_name="Jane",
last_name="Doe",
address="7 Alpine Street",
city="Maplegrove",
state="Wyoming",
country="USA",
phone_number="23454545",
email="[email protected]",
resume_file="",
user=u3
)
v1.save()
v2.save()
v3.save()
# test typical cases
self.assertTrue(has_resume_file(v1.id))
# test non-existant cases
self.assertFalse(has_resume_file(v2.id))
self.assertFalse(has_resume_file(v3.id))
开发者ID:ahmedsabie,项目名称:vms,代码行数:54,代码来源:tests.py
示例5: test_delete_volunteer
def test_delete_volunteer(self):
u1 = User.objects.create_user('Yoshi')
u2 = User.objects.create_user('Ashley')
u3 = User.objects.create_user('Zelda')
v1 = Volunteer(
first_name="Yoshi",
last_name="Doe",
address="7 Oak Street",
city="Elmgrove",
state="California",
country="USA",
phone_number="23454545",
email="[email protected]",
user=u1
)
v2 = Volunteer(
first_name="Ashley",
last_name="Doe",
address="7 Alpine Street",
city="Maplegrove",
state="Wyoming",
country="USA",
phone_number="23454545",
email="[email protected]",
user=u2
)
v3 = Volunteer(
id=999,
first_name="Zelda",
last_name="Doe",
address="7 Elm Street",
city="Oakgrove",
state="California",
country="USA",
phone_number="23454545",
email="[email protected]",
user=u3
)
v1.save()
v2.save()
v3.save()
self.assertTrue(delete_volunteer(v1.id))
self.assertTrue(delete_volunteer(v2.id))
self.assertTrue(delete_volunteer(v3.id))
self.assertFalse(delete_volunteer(100))
self.assertFalse(delete_volunteer(200))
self.assertFalse(delete_volunteer(300))
开发者ID:ahmedsabie,项目名称:vms,代码行数:53,代码来源:tests.py
示例6: test_get_all_volunteers
def test_get_all_volunteers(self):
""" Tests get_all_volunteers() """
u1 = User.objects.create_user('John')
u2 = User.objects.create_user('James')
u3 = User.objects.create_user('George')
v1 = Volunteer(
first_name="John",
last_name="Doe",
address="7 Alpine Street",
city="Maplegrove",
state="Wyoming",
country="USA",
phone_number="23454545",
email="[email protected]",
user=u1
)
v2 = Volunteer(
first_name="James",
last_name="Doe",
address="7 Oak Street",
city="Elmgrove",
state="California",
country="USA",
phone_number="23454545",
email="[email protected]",
user=u2
)
v3 = Volunteer(
id=999,
first_name="George",
last_name="Doe",
address="7 Elm Street",
city="Oakgrove",
state="California",
country="USA",
phone_number="23454545",
email="[email protected]",
user=u3
)
v1.save()
v2.save()
v3.save()
# test typical cases
self.assertIsNotNone(get_all_volunteers())
开发者ID:ahmedsabie,项目名称:vms,代码行数:50,代码来源:tests.py
示例7: test_delete_shift
def test_delete_shift(self):
""" Test delete_shift(shift_id) """
u1 = User.objects.create_user("Yoshi")
v1 = Volunteer(
first_name="Yoshi",
last_name="Turtle",
address="Mario Land",
city="Nintendo Land",
state="Nintendo State",
country="Nintendo Nation",
phone_number="2374983247",
email="[email protected]",
user=u1,
)
v1.save()
e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")
e1.save()
j1 = Job(
name="Software Developer",
start_date="2012-10-22",
end_date="2012-10-23",
description="A software job",
event=e1,
)
j1.save()
s1 = Shift(date="2012-10-23", start_time="1:00", end_time="12:00", max_volunteers=1, job=j1)
s2 = Shift(date="2011-11-11", start_time="11:00", end_time="12:00", max_volunteers=3, job=j1)
s1.save()
s2.save()
self.assertTrue(delete_shift(s1.id))
self.assertFalse(delete_shift(100))
register(v1.id, s2.id)
self.assertFalse(delete_shift(s2.id))
开发者ID:ahmedsabie,项目名称:vms,代码行数:44,代码来源:tests.py
示例8: create_volunteer_with_details_dynamic_password
def create_volunteer_with_details_dynamic_password(volunteer):
"""
Creates and returns volunteer with passed name and dates
"""
u1 = User.objects.create_user(username=volunteer[0], password=volunteer[1])
v1 = Volunteer(
email=volunteer[2],
first_name=volunteer[3],
last_name=volunteer[4],
address=volunteer[5],
city=volunteer[6],
state=volunteer[7],
country=volunteer[8],
phone_number=volunteer[9],
user=u1
)
v1.save()
return v1
开发者ID:systers,项目名称:vms,代码行数:19,代码来源:utils.py
示例9: create_volunteer_with_details
def create_volunteer_with_details(volunteer, org_obj):
"""
Creates and returns volunteer with passed name and dates
"""
u1 = User.objects.create_user(username=volunteer[0], password='volunteer')
v1 = Volunteer(
first_name=volunteer[1],
last_name=volunteer[2],
address=volunteer[3],
city=volunteer[4],
state=volunteer[5],
country=volunteer[6],
phone_number=volunteer[7],
email=volunteer[8],
user=u1,
organization=org_obj)
v1.save()
return v1
开发者ID:systers,项目名称:vms,代码行数:19,代码来源:utils.py
示例10: test_delete_volunteer_resume
def test_delete_volunteer_resume(self):
""" Tests delete_volunteer_resume(volunteer_id) """
u1 = User.objects.create_user('John')
v1 = Volunteer(
first_name="John",
last_name="Doe",
address="7 Alpine Street",
city="Maplegrove",
state="Wyoming",
country="USA",
phone_number="23454545",
email="[email protected]",
resume_file="MyResume.pdf",
user=u1
)
v1.save()
self.assertTrue(delete_volunteer_resume(v1.id))
self.assertFalse(delete_volunteer(100))
开发者ID:ahmedsabie,项目名称:vms,代码行数:21,代码来源:tests.py
示例11: apply
def apply(request):
form = request.POST
user = request.user
new_application = Volunteer(name=user.first_name + " "+user.last_name, email=user.email, phone=form.get('phone-number'), address=form.get('street-address'), city=form.get('city'), province=form.get('province'), isApproved=False, \
reference1name=form.get('ref1name'), reference1email=form.get('ref1email'), reference1phone=form.get('ref1phone'), \
reference2name=form.get('ref2name'), reference2email=form.get('ref2email'), reference2phone=form.get('ref2phone'), \
experience=form.get('id_experience'), availability=form.get('id_availability'))
if (form):
try:
new_application.save()
except IntegrityError, e:
fail_msg = "Sorry, record shows that your previous application has not been proccessed, please be patient (:"
return render_to_response('volunteer/apply.html', {'message': fail_msg})
email = form.get('email')
domain = request.META['HTTP_HOST']
link = domain + "/applications/" + str(new_application.id) + "/"
message = "To view the application, go to: " + link
send_mail('Writer\'s Exchange Volunteer Application', message, '[email protected]', [NOTIFICATION_EMAIL], fail_silently=False)
success_msg = "Thank you for your application! We will notify you about your application status soon."
return render_to_response('volunteer/apply.html', {'message': success_msg})
开发者ID:oliv9286,项目名称:WritersExchange,代码行数:24,代码来源:views.py
示例12: test_edit_shift_hours
def test_edit_shift_hours(self):
u1 = User.objects.create_user("Yoshi")
v1 = Volunteer(
first_name="Yoshi",
last_name="Turtle",
address="Mario Land",
city="Nintendo Land",
state="Nintendo State",
country="Nintendo Nation",
phone_number="2374983247",
email="[email protected]",
user=u1,
)
v1.save()
e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")
e1.save()
j1 = Job(
name="Software Developer",
start_date="2012-10-22",
end_date="2012-10-23",
description="A software job",
event=e1,
)
j1.save()
s1 = Shift(date="2012-10-23", start_time="1:00", end_time="12:00", max_volunteers=1, job=j1)
s1.save()
register(v1.id, s1.id)
self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id))
start_time = datetime.time(hour=9, minute=0)
end_time = datetime.time(hour=10, minute=0)
add_shift_hours(v1.id, s1.id, start_time, end_time)
start_time = datetime.time(hour=10, minute=0)
end_time = datetime.time(hour=11, minute=0)
edit_shift_hours(v1.id, s1.id, start_time, end_time)
volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id)
self.assertIsNotNone(volunteer_shift.start_time)
self.assertIsNotNone(volunteer_shift.end_time)
self.assertEqual(volunteer_shift.start_time, start_time)
self.assertEqual(volunteer_shift.end_time, end_time)
start_time = datetime.time(hour=1, minute=0)
end_time = datetime.time(hour=4, minute=0)
edit_shift_hours(v1.id, s1.id, start_time, end_time)
volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id)
self.assertIsNotNone(volunteer_shift.start_time)
self.assertIsNotNone(volunteer_shift.end_time)
self.assertEqual(volunteer_shift.start_time, start_time)
self.assertEqual(volunteer_shift.end_time, end_time)
start_time = datetime.time(hour=4, minute=15)
end_time = datetime.time(hour=12, minute=35)
edit_shift_hours(v1.id, s1.id, start_time, end_time)
volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id)
self.assertIsNotNone(volunteer_shift.start_time)
self.assertIsNotNone(volunteer_shift.end_time)
self.assertEqual(volunteer_shift.start_time, start_time)
self.assertEqual(volunteer_shift.end_time, end_time)
start_time = datetime.time(hour=2, minute=5)
end_time = datetime.time(hour=4, minute=15)
edit_shift_hours(v1.id, s1.id, start_time, end_time)
volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id)
self.assertIsNotNone(volunteer_shift.start_time)
self.assertIsNotNone(volunteer_shift.end_time)
self.assertEqual(volunteer_shift.start_time, start_time)
self.assertEqual(volunteer_shift.end_time, end_time)
start_time = datetime.time(hour=5, minute=0)
end_time = datetime.time(hour=5, minute=30)
edit_shift_hours(v1.id, s1.id, start_time, end_time)
volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id)
self.assertIsNotNone(volunteer_shift.start_time)
self.assertIsNotNone(volunteer_shift.end_time)
self.assertEqual(volunteer_shift.start_time, start_time)
self.assertEqual(volunteer_shift.end_time, end_time)
开发者ID:ahmedsabie,项目名称:vms,代码行数:86,代码来源:tests.py
示例13: test_get_unlogged_shifts_by_volunteer_id
def test_get_unlogged_shifts_by_volunteer_id(self):
u1 = User.objects.create_user("Yoshi")
v1 = Volunteer(
first_name="Yoshi",
last_name="Turtle",
address="Mario Land",
city="Nintendo Land",
state="Nintendo State",
country="Nintendo Nation",
phone_number="2374983247",
email="[email protected]",
user=u1,
)
v1.save()
e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")
e1.save()
j1 = Job(
name="Software Developer",
start_date="2012-10-22",
end_date="2012-10-23",
description="A software job",
event=e1,
)
j2 = Job(
name="Systems Administrator",
start_date="2012-9-1",
end_date="2012-10-26",
description="A systems administrator job",
event=e1,
)
j1.save()
j2.save()
s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)
s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)
s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)
s1.save()
s2.save()
s3.save()
# sign up
register(v1.id, s1.id)
register(v1.id, s2.id)
register(v1.id, s3.id)
# test typical case
shift_list = get_unlogged_shifts_by_volunteer_id(v1.id)
self.assertIsNotNone(shift_list)
self.assertNotEqual(shift_list, False)
self.assertEqual(len(shift_list), 3)
self.assertIn(s1, shift_list)
self.assertIn(s2, shift_list)
self.assertIn(s3, shift_list)
开发者ID:ahmedsabie,项目名称:vms,代码行数:64,代码来源:tests.py
示例14: test_get_volunteer_shift_by_id
def test_get_volunteer_shift_by_id(self):
u1 = User.objects.create_user("Yoshi")
u2 = User.objects.create_user("John")
v1 = Volunteer(
first_name="Yoshi",
last_name="Turtle",
address="Mario Land",
city="Nintendo Land",
state="Nintendo State",
country="Nintendo Nation",
phone_number="2374983247",
email="[email protected]",
user=u1,
)
v2 = Volunteer(
first_name="John",
last_name="Doe",
address="7 Alpine Street",
city="Maplegrove",
state="Wyoming",
country="USA",
phone_number="23454545",
email="[email protected]",
user=u2,
)
v1.save()
v2.save()
e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")
e1.save()
j1 = Job(
name="Software Developer",
start_date="2012-10-22",
end_date="2012-10-23",
description="A software job",
event=e1,
)
j2 = Job(
name="Systems Administrator",
start_date="2012-9-1",
end_date="2012-10-26",
description="A systems administrator job",
event=e1,
)
j1.save()
j2.save()
s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)
s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)
s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)
s1.save()
s2.save()
s3.save()
# test cases where signed up
register(v1.id, s1.id)
register(v1.id, s2.id)
register(v1.id, s3.id)
register(v2.id, s1.id)
register(v2.id, s2.id)
register(v2.id, s3.id)
self.assertEqual(
get_volunteer_shift_by_id(v1.id, s1.id), VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id)
)
self.assertEqual(
get_volunteer_shift_by_id(v1.id, s2.id), VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s2.id)
)
self.assertEqual(
get_volunteer_shift_by_id(v1.id, s3.id), VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s3.id)
)
# self.assertEqual(get_volunteer_shift_by_id(v2.id, s1.id),
# VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s1.id))
# why does this throw DoesNotExist?
self.assertEqual(
get_volunteer_shift_by_id(v2.id, s2.id), VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s2.id)
)
self.assertEqual(
get_volunteer_shift_by_id(v2.id, s3.id), VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s3.id)
)
开发者ID:ahmedsabie,项目名称:vms,代码行数:93,代码来源:tests.py
示例15: test_is_signed_up
def test_is_signed_up(self):
u1 = User.objects.create_user("Yoshi")
u2 = User.objects.create_user("John")
v1 = Volunteer(
first_name="Yoshi",
last_name="Turtle",
address="Mario Land",
city="Nintendo Land",
state="Nintendo State",
country="Nintendo Nation",
phone_number="2374983247",
email="[email protected]",
user=u1,
)
v2 = Volunteer(
first_name="John",
last_name="Doe",
address="7 Alpine Street",
city="Maplegrove",
state="Wyoming",
country="USA",
phone_number="23454545",
email="[email protected]",
user=u2,
)
v1.save()
v2.save()
e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")
e1.save()
j1 = Job(
name="Software Developer",
start_date="2012-10-22",
end_date="2012-10-23",
description="A software job",
event=e1,
)
j2 = Job(
name="Systems Administrator",
start_date="2012-9-1",
end_date="2012-10-26",
description="A systems administrator job",
event=e1,
)
j1.save()
j2.save()
s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)
s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)
s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)
s1.save()
s2.save()
s3.save()
# test cases where not signed up yet
self.assertFalse(is_signed_up(v1.id, s1.id))
self.assertFalse(is_signed_up(v1.id, s2.id))
self.assertFalse(is_signed_up(v1.id, s3.id))
# test cases where signed up
register(v1.id, s1.id)
register(v1.id, s2.id)
register(v1.id, s3.id)
self.assertTrue(is_signed_up(v1.id, s1.id))
self.assertTrue(is_signed_up(v1.id, s2.id))
self.assertTrue(is_signed_up(v1.id, s3.id))
# test case where more than one volunteer signs up for the same shift
self.assertFalse(is_signed_up(v2.id, s1.id))
self.assertFalse(is_signed_up(v2.id, s2.id))
self.assertFalse(is_signed_up(v2.id, s3.id))
register(v2.id, s2.id)
register(v2.id, s3.id)
self.assertFalse(is_signed_up(v2.id, s1.id))
self.assertTrue(is_signed_up(v2.id, s2.id))
self.assertTrue(is_signed_up(v2.id, s3.id))
开发者ID:ahmedsabie,项目名称:vms,代码行数:90,代码来源:tests.py
示例16: test_register
def test_register(self):
ERROR_CODE_ALREADY_SIGNED_UP = "ERROR_CODE_ALREADY_SIGNED_UP"
ERROR_CODE_NO_SLOTS_REMAINING = "ERROR_CODE_NO_SLOTS_REMAINING"
u1 = User.objects.create_user("Yoshi")
u2 = User.objects.create_user("John")
v1 = Volunteer(
first_name="Yoshi",
last_name="Turtle",
address="Mario Land",
city="Nintendo Land",
state="Nintendo State",
country="Nintendo Nation",
phone_number="2374983247",
email="[email protected]",
user=u1,
)
v2 = Volunteer(
first_name="John",
last_name="Doe",
address="7 Alpine Street",
city="Maplegrove",
state="Wyoming",
country="USA",
phone_number="23454545",
email="[email protected]",
user=u2,
)
v1.save()
v2.save()
e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")
e1.save()
j1 = Job(
name="Software Developer",
start_date="2012-10-22",
end_date="2012-10-23",
description="A software job",
event=e1,
)
j2 = Job(
name="Systems Administrator",
start_date="2012-9-1",
end_date="2012-10-26",
description="A systems administrator job",
event=e1,
)
j1.save()
j2.save()
s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)
s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)
s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)
s1.save()
s2.save()
s3.save()
# test typical cases
register(v1.id, s1.id)
self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id))
register(v1.id, s2.id)
self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s2.id))
register(v1.id, s3.id)
self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s3.id))
# test cases where volunteer tries to sign up for a shift
# they are already signed up for
self.assertEqual(register(v1.id, s1.id), ERROR_CODE_ALREADY_SIGNED_UP)
self.assertEqual(register(v1.id, s2.id), ERROR_CODE_ALREADY_SIGNED_UP)
self.assertEqual(register(v1.id, s3.id), ERROR_CODE_ALREADY_SIGNED_UP)
# test case where more than one volunteer signs up for the same shift
# v2 can't sign up for s1 because there are no slots remaining
self.assertEqual(register(v2.id, s1.id), ERROR_CODE_NO_SLOTS_REMAINING)
register(v2.id, s2.id)
self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s2.id))
register(v2.id, s3.id)
self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s3.id))
# test cases where a volunteer tries to sign up for a shift
# they are already signed up for
self.assertEqual(register(v2.id, s2.id), ERROR_CODE_ALREADY_SIGNED_UP)
self.assertEqual(register(v2.id, s3.id), ERROR_CODE_ALREADY_SIGNED_UP)
开发者ID:ahmedsabie,项目名称:vms,代码行数:98,代码来源:tests.py
示例17: test_search_volunteers
def test_search_volunteers(self):
u1 = User.objects.create_user('Yoshi')
u2 = User.objects.create_user('Ashley')
u3 = User.objects.create_user('Zelda')
o1 = Organization(organization_name = "Apple")
o2 = Organization(organization_name = "Google")
o1.save()
o2.save()
v1 = Volunteer(first_name = "Yoshi",
last_name = "Doe",
address = "7 Oak Street",
city = "Elmgrove",
state = "California",
country = "USA",
phone_number = "23454545",
organization = o1,
email = "[email protected]",
user = u1)
v2 = Volunteer(first_name = "Ashley",
last_name = "Doe",
address = "7 Alpine Street",
city = "Maplegrove",
state = "Wyoming",
country = "USA",
phone_number = "23454545",
organization = o2,
email = "[email protected]",
user = u2)
v3 = Volunteer(id = 999,
first_name = "Zelda",
last_name = "Doe",
address = "7 Elm Street",
city = "Oakgrove",
state = "California",
country = "USA",
phone_number = "23454545",
unlisted_organization = "Government of Canada",
email = "[email protected]",
user = u3)
v1.save()
v2.save()
v3.save()
#if no search parameters are given, it returns all volunteers
search_list = search_volunteers("", "", "", "", "", "")
self.assertNotEqual(search_list, False)
self.assertEqual(len(search_list), 3)
self.assertIn(v1, search_list)
self.assertIn(v2, search_list)
self.assertIn(v3, search_list)
search_list = search_volunteers(None, None, None, None, None, None)
self.assertNotEqual(search_list, False)
self.assertEqual(len(search_list), 3)
self.assertIn(v1, search_list)
self.assertIn(v2, search_list)
self.assertIn(v3, search_list)
#test exact search
search_list = search_volunteers("Yoshi", "Doe", "Elmgrove", "California", "USA", "Apple")
self.assertNotEqual(search_list, False)
self.assertEqual(len(search_list), 1)
self.assertIn(v1, search_list)
self.assertNotIn(v2, search_list)
self.assertNotIn(v3, search_list)
#test partial search
search_list = search_volunteers("Yoshi", None, None, None, None, None)
self.assertNotEqual(search_list, False)
self.assertEqual(len(search_list), 1)
self.assertIn(v1, search_list)
self.assertNotIn(v2, search_list)
self.assertNotIn(v3, search_list)
search_list = search_volunteers(None, "Doe", None, None, None, None)
self.assertNotEqual(search_list, False)
self.assertEqual(len(search_list), 3)
self.assertIn(v1, search_list)
self.assertIn(v2, search_list)
self.assertIn(v3, search_list)
#test no search matches
search_list = search_volunteers("Billy", "Doe", "Montreal", "Quebec", "Canada", "Ubisoft")
self.assertEqual(len(search_list), 0)
self.assertNotIn(v1, search_list)
self.assertNotIn(v2, search_list)
self.assertNotIn(v3, search_list)
开发者ID:Nerdylicious,项目名称:vms-pre-integration,代码行数:94,代码来源:tests.py
示例18: test_get_shifts_signed_up_for
def test_get_shifts_signed_up_for(self):
u1 = User.objects.create_user('Yoshi')
v1 = Volunteer(first_name = "Yoshi",
last_name = "Turtle",
address = "Mario Land",
city = "Nintendo Land",
state = "Nintendo State",
country = "Nintendo Nation",
phone_number = "2374983247",
email = "[email protected]",
user = u1)
v1.save()
j1 = Job(job_title = "Software Developer",
start_date = "2012-10-22",
end_date = "2012-10-23",
description = "A software job")
j2 = Job(job_title = "Systems Administrator",
start_date = "2012-9-1",
end_date = "2012-10-26",
description = "A systems administrator job")
j1.save()
j2.save()
s1 = Shift(date = "2012-10-23",
location = "Google Drive",
start_time = "9:00",
end_time = "3:00",
max_volunteers = 1,
slots_remaining = 1,
job = j1)
s2 = Shift(date = "2012-10-23",
location = "Infinite Loop",
start_time = "10:00",
end_time = "4:00",
max_volunteers = 2,
slots_remaining = 2,
job = j1)
s3 = Shift(date = "2012-10-23",
location = "Loopy Loop Road",
start_time = "12:00",
end_time = "6:00",
max_volunteers = 4,
slots_remaining = 4,
job = j2)
s1.save()
s2.save()
s3.save()
#sign up
register(v1.id, s1.id)
register(v1.id, s2.id)
register
|
请发表评论