blob: c1ddfeea90629e5c4ca3ebb1a8bf6dc78918c05b [file] [log] [blame]
# Copyright 2014 the Melange authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Unit tests for program logic."""
import unittest
from seeder import profile as profile_seeder
from seeder import document as document_seeder
from seeder import program as program_seeder
from soc.logic import program as program_logic
class GetTermsOfServiceTest(unittest.TestCase):
"""Unit tests for getTermsOfService function."""
def setUp(self):
"""See unittest.TestCase.setUp for specification."""
self.program = program_seeder.seedProgram()
self.student_agreement = document_seeder.seedDocument(self.program)
self.mentor_agreement = document_seeder.seedDocument(self.program)
self.program.student_agreement = self.student_agreement
self.program.mentor_agreement = self.mentor_agreement
self.program.put()
def testForOrgMemberProfile(self):
"""Tests that ToS document is returned for organization members."""
profile = profile_seeder.seedProfile(self.program.key())
# check that correct ToS document is returned
terms_of_service = program_logic.getTermsOfService(self.program, profile)
self.assertEqual(self.mentor_agreement.key(), terms_of_service.key())
# check if no ToS document is defined
self.program.mentor_agreement = None
self.program.put()
terms_of_service = program_logic.getTermsOfService(self.program, profile)
self.assertIsNone(terms_of_service)
def testForStudentProfile(self):
"""Tests that ToS document is returned for students."""
profile = profile_seeder.seedStudent(self.program)
# check that correct ToS document is returned
terms_of_service = program_logic.getTermsOfService(self.program, profile)
self.assertEqual(self.student_agreement.key(), terms_of_service.key())
# check if no ToS document is defined
self.program.student_agreement = None
self.program.put()
terms_of_service = program_logic.getTermsOfService(self.program, profile)
self.assertIsNone(terms_of_service)