예제 #1
0
    def test_authenticated_user_with_agreement(self):
        authenticated_user = self.get_authenticated_user()
        authenticated_user.agreements.append(self.agreement.pk)

        result = get_required_user_agreement(authenticated_user,
                                             self.agreements)
        self.assertIsNone(result)
예제 #2
0
    def test_prioritize_terms_of_service(self):
        terms_of_service = Agreement.objects.create(
            type=Agreement.TYPE_TOS,
            link='https://somewhre.com',
            text='Lorem ipsum',
            is_active=True,
        )

        agreements = Agreement.objects.get_agreements_from_db()
        agreements_in_wrong_order = {
            Agreement.TYPE_PRIVACY: agreements[Agreement.TYPE_PRIVACY],
            Agreement.TYPE_TOS: agreements[Agreement.TYPE_TOS],
        }

        authenticated_user = self.get_authenticated_user()
        result = get_required_user_agreement(authenticated_user,
                                             agreements_in_wrong_order)
        self.assertEqual(result, terms_of_service)
예제 #3
0
 def test_authenticated_user_no_agreements(self):
     authenticated_user = self.get_authenticated_user()
     result = get_required_user_agreement(authenticated_user, {})
     self.assertIsNone(result)
예제 #4
0
 def test_authenticated_user(self):
     authenticated_user = self.get_authenticated_user()
     result = get_required_user_agreement(authenticated_user,
                                          self.agreements)
     self.assertEqual(result, self.agreement)
예제 #5
0
 def test_anonymous_user(self):
     anonymous_user = self.get_anonymous_user()
     result = get_required_user_agreement(anonymous_user, self.agreements)
     self.assertIsNone(result)