예제 #1
0
    def test_company_user_auth_succeeds_for_valid_account(self):
        """Verify that a company rep user can log in if their company's
        subscription is not expired.
        """
        # Create a company rep for the user, with a company that is active
        # (is_expired returns False)
        company = Company(name='Test Company',
                          expiration_date=datetime.date.today())
        company.save()
        with patch.object(Company, 'is_expired',
                          return_value=False) as mock_is_expired:
            rep = CompanyRep(user=self.user, company=company)
            rep.save()

            # Ensure that the user can be authenticated
            form = AuthenticationForm(None, self.form_data)
            self.assertTrue(form.is_valid())
        self.assertEquals(mock_is_expired.call_count, 1)
예제 #2
0
파일: tests.py 프로젝트: nbailey/quark
    def test_company_user_auth_succeeds_for_valid_account(self):
        """Verify that a company rep user can log in if their company's
        subscription is not expired.
        """
        # Create a company rep for the user, with a company that is active
        # (is_expired returns False)
        company = Company(name='Test Company',
                          expiration_date=datetime.date.today())
        company.save()
        with patch.object(Company, 'is_expired',
                          return_value=False) as mock_is_expired:
            rep = CompanyRep(user=self.user, company=company)
            rep.save()

            # Ensure that the user can be authenticated
            form = AuthenticationForm(None, self.form_data)
            self.assertTrue(form.is_valid())
        self.assertEquals(mock_is_expired.call_count, 1)
예제 #3
0
    def test_company_user_auth_fails_for_expired_account(self):
        """Verify that a company rep user cannot log in if their company's
        subscription is expired.
        """
        # Create a company rep for the user, with a company that has an expired
        # subscription (is_expired returns True)
        company = Company(name='Test Company',
                          expiration_date=datetime.date.today())
        company.save()
        with patch.object(Company, 'is_expired',
                          return_value=True) as mock_is_expired:
            rep = CompanyRep(user=self.user, company=company)
            rep.save()

            # Ensure that the user cannot be authenticated
            form = AuthenticationForm(None, self.form_data)
            self.assertFalse(form.is_valid())
            expected_error_msg = (
                '{}\'s subscription to this website has expired'.format(
                    company.name))
            self.assertIn(expected_error_msg, form.non_field_errors()[0])
        self.assertEquals(mock_is_expired.call_count, 1)
예제 #4
0
파일: tests.py 프로젝트: nbailey/quark
    def test_company_user_auth_fails_for_expired_account(self):
        """Verify that a company rep user cannot log in if their company's
        subscription is expired.
        """
        # Create a company rep for the user, with a company that has an expired
        # subscription (is_expired returns True)
        company = Company(name='Test Company',
                          expiration_date=datetime.date.today())
        company.save()
        with patch.object(Company, 'is_expired',
                          return_value=True) as mock_is_expired:
            rep = CompanyRep(user=self.user, company=company)
            rep.save()

            # Ensure that the user cannot be authenticated
            form = AuthenticationForm(None, self.form_data)
            self.assertFalse(form.is_valid())
            expected_error_msg = (
                '{}\'s subscription to this website has expired'.format(
                    company.name))
            self.assertIn(expected_error_msg, form.non_field_errors()[0])
        self.assertEquals(mock_is_expired.call_count, 1)
예제 #5
0
 def test_regular_user_auth_succeeds(self):
     """Test whether a non-company user can log in as expected."""
     form = AuthenticationForm(None, self.form_data)
     self.assertTrue(form.is_valid())
예제 #6
0
파일: tests.py 프로젝트: nbailey/quark
 def test_regular_user_auth_succeeds(self):
     """Test whether a non-company user can log in as expected."""
     form = AuthenticationForm(None, self.form_data)
     self.assertTrue(form.is_valid())