Esempio n. 1
0
    def setUp(self):
        self.backend = DummyCyclosBackend()
        set_backend(self.backend)

        self.group_1 = CyclosGroupFactory.create(initial=True)
        self.groupset = CyclosGroupSetFactory.create(
            groups=[self.group_1, ])
        self.community = CC3CommunityFactory.create(
            groupsets=[self.groupset], code='TST')

        # Create business with its terminal.
        self.user_1 = UserFactory.create()
        self.terminal_1 = TerminalFactory.create(business=self.user_1)
        self.token_1 = Token.objects.create(user=self.user_1)
        self.operator_1 = OperatorFactory(business=self.user_1)
        self.cc3profile_1 = CC3ProfileFactory.create(
            user=self.user_1, first_name='Test', last_name='Business',
            community=self.community, cyclos_group=self.group_1)
        self.business_settings = BusinessCauseSettingsFactory.create(
            user=self.user_1)

        # Create card users.
        self.user_2 = UserFactory.create()
        self.cc3profile_2 = CC3ProfileFactory.create(
            user=self.user_2, first_name='Test', last_name='User',
            community=self.community, cyclos_group=self.group_1)
        self.user_cause = UserCauseFactory.create(consumer=self.user_2)

        self.community_2 = CC3CommunityFactory.create(
            groupsets=[self.groupset], code='TST')

        self.user_3 = UserFactory.create()
        self.cc3profile_3 = CC3ProfileFactory.create(
            user=self.user_3, first_name='Test', last_name='User',
            community=self.community_2, cyclos_group=self.group_1)

        self.user_4 = UserFactory.create()
        self.terminal_4 = TerminalFactory.create(business=self.user_4)
        self.token_4 = Token.objects.create(user=self.user_4)
        self.operator_4 = OperatorFactory(business=self.user_4)

        self.client = self.client_class(HTTP_AUTHORIZATION='Token {0}'.format(
            self.token_1.key))
        self.card_2 = CardFactory.create(owner=self.user_2)
        self.card_3 = CardFactory.create(owner=self.user_3)

        self.url = reverse(
            'api_cards_card_reward', args=[self.card_2.number.uid_number])

        self.post_data = {
            'terminal_name': self.terminal_1.name,
            'operator_name': self.operator_1.name,
            'sender_id': self.operator_1.business.id,
            'receiver_id': self.card_2.owner.id,
            'amount': '100',
            'description': 'Reward to good cause {0}'.format(
                self.user_cause.cause)
        }
Esempio n. 2
0
    def setUp(self):
        community = CC3CommunityFactory.create()
        category = CategoryFactory.create()

        self.form = CC3ProfileForm()

        self.form.cleaned_data = {
            'community': community.pk,
            'first_name': 'John',
            'last_name': 'Doe',
            'business_name': 'Maykin Media',
            'job_title': 'Developer',
            'country': 'NL',
            'city': 'Amsterdam',
            'address': 'Herengracht 416',
            'postal_code': '1017BZ',
            'phone_number': '+31 (0)207530523',
            'mobile_number': '+31 616844084',
            'company_website': 'http://www.maykinmedia.nl',
            'company_description': 'We provide hassle-free, custom-made '
            'websites and webapps for clients.',
            'is_visible': True,
            'categories': [category]
        }

        activate('en')
Esempio n. 3
0
    def setUp(self):
        set_backend(DummyCyclosBackend())

        self.group_1 = CyclosGroupFactory.create(initial=True)
        self.group_2 = CyclosGroupFactory.create()
        self.group_3 = CyclosGroupFactory.create()
        self.groupset = CyclosGroupSetFactory.create(
            groups=[self.group_1, self.group_2, self.group_3])

        self.community = CC3CommunityFactory.create(groupsets=[self.groupset])

        self.profile = CC3ProfileFactory.create(community=self.community,
                                                cyclos_group=CyclosGroupFactory(
                                                    name=settings.CYCLOS_CUSTOMER_MEMBER_GROUP))

        self.member_profile = AuthUserProfileFactory.create(
            groupset=self.groupset,
            community=self.community,
            business_name='MaykinMedia',
            web_payments_enabled=True)

        self.member_empty_profile = CC3ProfileFactory.create()

        # Create a Cyclos account for the 'member_profile'.
        self.cyclos_account = CyclosAccountFactory.create(
            cc3_profile=self.profile)
    def setUp(self):
        activate(settings.LANGUAGE_CODE)
        set_backend(DummyCyclosBackend())

        self.group_1 = CyclosGroupFactory.create(initial=True)
        self.group_2 = CyclosGroupFactory.create()
        self.group_3 = CyclosGroupFactory.create()

        self.groupset = CyclosGroupSetFactory.create(
            groups=[self.group_1, self.group_2, self.group_3])

        self.community = CC3CommunityFactory.create(groupsets=[self.groupset])

        self.from_profile = CC3ProfileFactory.create(community=self.community)
        self.to_profile = CC3ProfileFactory.create(groupset=self.groupset,
                                                   community=self.community,
                                                   business_name='MaykinMedia')

        self.invoice = InvoiceFactory.create(from_user=self.from_profile.user,
                                             to_user=self.to_profile.user)
        self.user_1 = UserFactory.create()
        self.staff_user = UserFactory.create(is_staff=True)

        self.community_admin_profile = CC3ProfileFactory.create(
            community=self.community)
        self.community_admin = CommunityAdminFactory.create(
            user=self.community_admin_profile.user, community=self.community)
        self.url = reverse('invoice_download_pdf', args=[self.invoice.id])
Esempio n. 5
0
    def setUp(self):
        self.community = CC3CommunityFactory.create()
        self.category = CategoryFactory.create()

        self.form = CommunityBusinessProfileForm()
        self.form_data = {
            'business_name': 'Maykin Media',
            'city': 'Amsterdam',
            'address': 'Herengracht',
            'postal_code': '1017BZ',
            'extra_address': '',
            'phone_number': '+31 (0)20 753 05 23',
            'company_website': 'http://www.maykinmedia.nl',
            'company_description': 'Web development studio.',
            'community': self.community,
            'categories': [self.category],
            'email': '*****@*****.**',
            'first_name': 'Alex',
            'tussenvoegsel': 'de',
            'last_name': 'Landgraaf',
            'num_street': '416',
            'gender': 'M',
            'date_of_birth': None,
            'iban': 'NL39RABO0300065264',
            'bic_code': 'RABONL78342',
            'signature_date': date.today()
        }
Esempio n. 6
0
    def setUp(self):
        set_backend(DummyCyclosBackend())

        self.group_1 = CyclosGroupFactory.create(initial=True)
        self.group_2 = CyclosGroupFactory.create()
        self.group_3 = CyclosGroupFactory.create()
        self.groupset = CyclosGroupSetFactory.create(
            groups=[self.group_1, self.group_2, self.group_3])

        self.community = CC3CommunityFactory.create(groupsets=[self.groupset])

        self.profile = CC3ProfileFactory.create(community=self.community)
        self.member_profile = AuthUserProfileFactory.create(
            groupset=self.groupset,
            community=self.community,
            business_name='MaykinMedia',
            web_payments_enabled=True)

        self.member_empty_profile = CC3ProfileFactory.create()

        # Create a Cyclos account for the 'member_profile'.
        self.cyclos_account = CyclosAccountFactory.create(
            cc3_profile=self.profile)

        self.ad = AdFactory.create(created_by=self.profile)

        self.url = reverse('accounts_edit_ad', kwargs={'pk': self.ad.pk})
Esempio n. 7
0
    def setUp(self):
        self.backend = DummyCyclosBackend()
        set_backend(self.backend)

        admin_user_1 = UserFactory.create(is_staff=True,
                                          is_active=True,
                                          is_superuser=True)
        cyclos_group_1 = CyclosGroupFactory.create(initial=True,
                                                   invoice_user=admin_user_1)
        cyclos_groupset_1 = CyclosGroupSetFactory.create(
            groups=[cyclos_group_1])
        community_1 = CC3CommunityFactory.create(groupsets=[cyclos_groupset_1])
        self.community_registration = CommunityRegistrationCodeFactory.create(
            community=community_1, groupset=cyclos_groupset_1)

        self.profile = AuthUserProfileFactory.create(web_payments_enabled=True,
                                                     community=community_1)

        self.terminal_1 = TerminalFactory.create(business=self.profile.user)
        self.token_1 = Token.objects.create(user=self.profile.user)
        self.operator_1 = OperatorFactory(business=self.profile.user)
        self.client = self.client_class(
            HTTP_AUTHORIZATION='Token {0}'.format(self.token_1.key))

        self.card_number_1 = CardNumberFactory.create(number='55555')
        self.card_number_2 = CardNumberFactory.create(number='55556')
        self.card_number_3 = CardNumberFactory.create(number='55557')
Esempio n. 8
0
    def test_results_include_all_communities(self):
        """ Contacts from all communities INTER_COMMUNITIES_TRANSACTIONS """
        another_community = CC3CommunityFactory.create()
        another_community.groupsets.add(self.groupset)

        profile = UserProfileFactory.create(community=another_community,
                                            cyclos_group=self.init_group)
        IndividualProfileFactory.create(profile=profile)

        #        profile = CC3ProfileFactory.create(community=another_community)

        self.client.login(username=profile.user.username, password='******')

        response = self.client.get(reverse(
            'contact_name_auto', kwargs={'community': another_community.pk}), {
                'contact_name': "CC3P",
            },
                                   HTTP_X_REQUESTED_WITH='XMLHttpRequest')

        self.assertEqual(response.status_code, 200)

        data = json.loads(response.content)

        # Must be at least 1 user, created above, plus users from `setUp`
        # should be present here.
        self.assertGreater(len(data), 1)
Esempio n. 9
0
    def setUp(self):
        set_backend(DummyCyclosBackend())

        self.group_1 = CyclosGroupFactory.create(initial=True)
        self.group_2 = CyclosGroupFactory.create()
        self.group_3 = CyclosGroupFactory.create()
        self.groupset = CyclosGroupSetFactory.create(
            groups=[self.group_1, self.group_2, self.group_3])

        self.community = CC3CommunityFactory.create(groupsets=[self.groupset])

        self.profile = CC3ProfileFactory.create(community=self.community)
        self.member_profile = CC3ProfileFactory.create(
            groupset=self.groupset, community=self.community)
        self.member_empty_profile = CC3ProfileFactory.create()

        CommunityAdminFactory.create(user=self.profile.user,
                                     community=self.profile.community)

        # Create a Cyclos account for the 'member_profile'.
        self.cyclos_account = CyclosAccountFactory.create(
            cc3_profile=self.member_profile)

        self.ad = AdFactory.create(created_by=self.member_profile)

        self.url = reverse('communityadmin_ns:edit_ad',
                           kwargs={'pk': self.ad.pk})
Esempio n. 10
0
    def setUp(self):
        self.backend = DummyCyclosBackend()
        set_backend(self.backend)

        self.init_group = CyclosGroup.objects.create(id=1,
                                                     name='init_group',
                                                     initial=True)
        self.community = CC3CommunityFactory.create()
        self.groupset = CyclosGroupSet.objects.create(
            pk=settings.STADLANDER_GROUPSET_ID,
            name='Groupset',
            slug='groupset')
        self.groupset.groups.add(self.init_group)
        self.community.groupsets.add(self.groupset)

        self.profile_1 = UserProfileFactory.create(
            community=self.community, cyclos_group=self.init_group)
        self.individual_profile_1 = IndividualProfileFactory.create(
            profile=self.profile_1)
        self.profile_2 = UserProfileFactory.create(
            community=self.community, cyclos_group=self.init_group)
        self.individual_profile_2 = IndividualProfileFactory.create(
            profile=self.profile_2)
        self.profile_3 = UserProfileFactory.create(
            community=self.community, cyclos_group=self.init_group)
        self.individual_profile_3 = IndividualProfileFactory.create(
            profile=self.profile_3)
        self.profile_firstname_1 = UserProfileFactory.create(
            community=self.community,
            first_name="John",
            last_name="Smith",
            cyclos_group=self.init_group,
        )
        self.individual_profile_firstname_1 = IndividualProfileFactory.create(
            profile=self.profile_firstname_1)

        self.profile_firstname_2 = UserProfileFactory.create(
            community=self.community,
            first_name="John",
            last_name="Dyke",
            cyclos_group=self.init_group,
        )
        self.individual_profile_firstname_2 = IndividualProfileFactory.create(
            profile=self.profile_firstname_2)
        self.profile_firstname_3 = UserProfileFactory.create(
            community=self.community,
            first_name="John",
            last_name="Smith-Black",
            cyclos_group=self.init_group,
        )
        self.individual_profile_firstname_3 = IndividualProfileFactory.create(
            profile=self.profile_firstname_3)
        self.profile_firstname_4 = UserProfileFactory.create(
            community=self.community,
            first_name="Jan de",
            last_name="Waar",
            cyclos_group=self.init_group,
        )
        self.individual_profile_firstname_4 = IndividualProfileFactory.create(
            profile=self.profile_firstname_4)
Esempio n. 11
0
    def test_community_results(self):
        """ Only contacts from own community !INTER_COMMUNITIES_TRANSACTIONS """
        new_community = CC3CommunityFactory.create()
        new_community.groupsets.add(self.groupset)

        member = UserProfileFactory.create(community=new_community,
                                           cyclos_group=self.init_group)
        IndividualProfileFactory.create(profile=member)

        profile = UserProfileFactory.create(community=new_community,
                                            cyclos_group=self.init_group)
        IndividualProfileFactory.create(profile=profile)

        self.client.login(username=profile.user.username, password='******')

        response = self.client.get(reverse(
            'contact_name_auto', kwargs={'community': new_community.pk}), {
                'contact_name': "CC3P",
            },
                                   HTTP_X_REQUESTED_WITH='XMLHttpRequest')

        self.assertEqual(response.status_code, 200)

        data = json.loads(response.content)

        # Must be only 1 user: the one we created above. No users from `setUp`
        # should be present here.
        self.assertEqual(len(data), 1)
        self.assertEqual(data[0]['pk'], member.pk)
Esempio n. 12
0
    def setUp(self):
        self.backend = DummyCyclosBackend()
        set_backend(self.backend)

        admin_user_1 = UserFactory.create(is_staff=True,
                                          is_active=True,
                                          is_superuser=True)
        cyclos_group_1 = CyclosGroupFactory.create(initial=True,
                                                   invoice_user=admin_user_1)
        cyclos_groupset_1 = CyclosGroupSetFactory.create(
            groups=[cyclos_group_1])
        community_1 = CC3CommunityFactory.create(groupsets=[cyclos_groupset_1])

        self.profile = AuthUserProfileFactory.create(
            web_payments_enabled=True,
            community=community_1,
            terms_and_conditions=True,
            cyclos_group=cyclos_group_1)
        self.profile.first_login = False
        self.profile.save()

        self.individual_profile_1 = \
            IndividualProfileFactory.create(profile=self.profile)
        self.user_cause = UserCauseFactory.create(consumer=self.profile.user)

        self.profile_2 = AuthUserProfileFactory.create(
            web_payments_enabled=True,
            community=community_1,
            terms_and_conditions=True,
            cyclos_group=cyclos_group_1)
        self.individual_profile_2 = \
            IndividualProfileFactory.create(profile=self.profile_2)
        self.user_cause_2 = UserCauseFactory.create(
            consumer=self.profile_2.user)
Esempio n. 13
0
    def setUp(self):
        self.community = CC3CommunityFactory.create()
        self.category = CategoryFactory.create()

        self.form = CommunityUserProfileForm()

        self.date_of_birth = date(1976, 11, 18)

        self.form_data = {
            'business_name': 'Maykin Media',
            'city': 'Amsterdam',
            'address': 'Herengracht',
            'postal_code': '1017BZ',
            'extra_address': '',
            'phone_number': '+31 (0)20 753 05 23',
            'company_website': 'http://www.maykinmedia.nl',
            'company_description': 'Web development studio.',
            'community': self.community,
            'categories': [self.category],
            'email': '*****@*****.**',
            'first_name': 'Alex',
            'tussenvoegsel': 'de',
            'last_name': 'Landgraaf',
            'num_street': '416',
            'gender': 'M',
            'date_of_birth': self.date_of_birth,

        }
Esempio n. 14
0
    def setUp(self):
        # Django CMS Page.
        self.placeholder = CMSPlaceholderFactory.create()
        self.page = CMSPageFactory.create(placeholders=(self.placeholder, ))

        self.url = reverse('communityadmin_ns:contentlist')

        self.profile = CC3ProfileFactory.create()
        self.anonymous_profile = CC3ProfileFactory.create()

        CommunityAdminFactory.create(user=self.profile.user,
                                     community=self.profile.community)

        # Create a separated Community.
        self.community = CC3CommunityFactory.create()

        # Create some Community messages. `CommunityMessages` belong to a
        # Django CMS `CommunityPlugin`.
        self.plugin = CommunityPluginModelFactory.create(
            placeholder=self.placeholder)

        self.message_1 = CommunityMessageFactory.create(
            plugin=self.plugin,
            community=self.community,
            plugin__placeholder__page__publisher_is_draft=True)
        self.message_2 = CommunityMessageFactory.create(
            plugin=self.plugin,
            community=self.profile.community,
            plugin__placeholder__page__publisher_is_draft=True)
        self.message_3 = CommunityMessageFactory.create(
            plugin=self.plugin,
            community=self.profile.community,
            plugin__placeholder__page__publisher_is_draft=True)

        self.factory = RequestFactory()
Esempio n. 15
0
    def setUp(self):
        self.backend = DummyCyclosBackend()
        set_backend(self.backend)

        self.group_1 = CyclosGroupFactory.create(initial=True)
        self.groupset = CyclosGroupSetFactory.create(
            groups=[self.group_1, ])
        self.community = CC3CommunityFactory.create(
            groupsets=[self.groupset], code='TST')

        self.user_1 = UserFactory.create()
        self.terminal_1 = TerminalFactory.create(business=self.user_1)
        self.token_1 = Token.objects.create(user=self.user_1)
        self.operator_1 = OperatorFactory(business=self.user_1)
        self.cc3profile_1 = CC3ProfileFactory.create(
            user=self.user_1, first_name='Test', last_name='Business',
            community=self.community, cyclos_group=self.group_1)
        self.user_2 = UserFactory.create()
        self.cc3profile_2 = CC3ProfileFactory.create(
            user=self.user_2, first_name='Test', last_name='User',
            community=self.community, cyclos_group=self.group_1)

        self.user_3 = UserFactory.create()

        self.user_4 = UserFactory.create()
        self.terminal_4 = TerminalFactory.create(business=self.user_4)
        self.token_4 = Token.objects.create(user=self.user_4)
        self.operator_4 = OperatorFactory(business=self.user_4)

        self.client = self.client_class(HTTP_AUTHORIZATION='Token {0}'.format(
            self.token_1.key))
        self.card_2 = CardFactory.create(owner=self.user_2)
        self.card_3 = CardFactory.create(owner=self.user_3)

        self.community_5 = CC3CommunityFactory.create(
            groupsets=[self.groupset])
        self.user_5 = UserFactory.create()
        self.cc3profile_5 = CC3ProfileFactory.create(
            user=self.user_5, first_name='Test', last_name='User5',
            community=self.community_5, cyclos_group=self.group_1)
        self.card_5 = CardFactory.create(owner=self.user_5)
        self.blocked_card = CardFactory.create(owner=self.user_2)
        self.blocked_card.block_card()

        self.url = reverse(
            'api_cards_card_payment', args=[self.card_2.number.uid_number])
Esempio n. 16
0
 def setUp(self):
     self.backend = DummyCyclosBackend()
     set_backend(self.backend)
     self.cyclos_group = CyclosGroupFactory.create(initial=True)
     self.cyclos_groupset = CyclosGroupSetFactory.create(
         groups=[self.cyclos_group])
     self.community = CC3CommunityFactory.create(
         groupsets=[self.cyclos_groupset])
     self.community_registration = CommunityRegistrationCodeFactory.create(
         community=self.community, groupset=self.cyclos_groupset)
Esempio n. 17
0
    def test_non_existent_community(self):
        """
        Tests returning a 404 error when the user tries to retrieve results
        from a community he doesn't belong to.
        """
        non_community = CC3CommunityFactory.create()
        self.client.login(username=self.profile_3.user.username,
                          password='******')

        response = self.client.get(reverse(
            'contact_name_auto', kwargs={'community': non_community.pk}), {
                'contact_name': "CC3P",
            },
                                   HTTP_X_REQUESTED_WITH='XMLHttpRequest')

        self.assertEqual(response.status_code, 404)
Esempio n. 18
0
    def setUp(self):
        self.backend = DummyCyclosBackend()
        set_backend(self.backend)

        self.papi_key = ''.join(
            random.choice(string.hexdigits) for _ in range(64))
        self.sl_login_url = reverse('stadlander_login')

        self.init_group = CyclosGroup.objects.create(id=1,
                                                     name='init_group',
                                                     initial=True)
        self.community = CC3CommunityFactory()
        self.comm_woon = CommunityWoonplaat.objects.create(
            community=self.community, woonplaat='Amsterdam')
        # don't really know why this is necessary, but ...
        try:
            self.groupset = CyclosGroupSet.objects.get(
                pk=settings.STADLANDER_GROUPSET_ID)
        except CyclosGroupSet.DoesNotExist:
            self.groupset = CyclosGroupSet.objects.create(
                pk=settings.STADLANDER_GROUPSET_ID,
                name='Groupset',
                slug='groupset')
        self.groupset.groups.add(self.init_group)
        self.community.groupsets.add(self.groupset)
        self.user_profile = UserProfileFactory(community=self.community)

        self.individual_profile = IndividualProfileFactory(
            profile=self.user_profile)
        self.defaultgoodcause = DefaultGoodCauseUserFactory.create(
            community=self.user_profile.community)
        # set a default good cause for the profile
        self.individual_profile.set_good_cause()
        self.rule = RuleFactory.create(
            action_class=u"icare4u_front.stadlander.actions.PayStadlander",
            parameter_names=u"sender,amount",
            parameter_values="stadlander,25",
            process_model=ContentType.objects.get_for_model(User),
            instance_identifier='persoonsnummer',
        )

        self.user = self.user_profile.user

        self.factory = RequestFactory()
Esempio n. 19
0
    def setUp(self):
        self.backend = DummyCyclosBackend()
        set_backend(self.backend)

        self.sso_backend = StadlanderSSOBackend()
        activate('en')
        self.init_group = CyclosGroup.objects.create(id=1,
                                                     name='init_group',
                                                     initial=True)
        self.community = CC3CommunityFactory()
        self.comm_woon = CommunityWoonplaat.objects.create(
            community=self.community, woonplaat='Amsterdam')
        # don't really know why this is necessary, but ...
        try:
            self.groupset = CyclosGroupSet.objects.get(
                pk=settings.STADLANDER_GROUPSET_ID)
        except:
            self.groupset = CyclosGroupSet.objects.create(
                pk=settings.STADLANDER_GROUPSET_ID,
                name='Groupset',
                slug='groupset')
        self.groupset.groups.add(self.init_group)
        self.community.groupsets.add(self.groupset)
        self.user_profile = UserProfileFactory(community=self.community)

        self.individual_profile = IndividualProfileFactory(
            profile=self.user_profile)
        self.st_profile = StadlanderProfile.objects.create(
            rel_number=123, profile=self.user_profile)

        self.defaultgoodcause = DefaultGoodCauseUserFactory.create(
            community=self.user_profile.community)
        # set a default good cause for the profile
        self.individual_profile.set_good_cause()
        self.rule = RuleFactory.create(
            action_class=u"icare4u_front.stadlander.actions.PayStadlander",
            parameter_names=u"sender,amount",
            parameter_values="stadlander,25",
            process_model=ContentType.objects.get_for_model(User),
            instance_identifier='persoonsnummer',
        )
Esempio n. 20
0
    def setUp(self):
        set_backend(DummyCyclosBackend())

        self.group_1 = CyclosGroupFactory.create(initial=True)
        self.group_2 = CyclosGroupFactory.create()
        self.group_3 = CyclosGroupFactory.create()
        self.groupset = CyclosGroupSetFactory.create(
            groups=[self.group_1, self.group_2, self.group_3])

        self.community = CC3CommunityFactory.create(groupsets=[self.groupset])

        self.profile = CC3ProfileFactory.create(community=self.community)
        self.member_profile = CC3ProfileFactory.create(
            groupset=self.groupset, community=self.community)
        self.member_empty_profile = CC3ProfileFactory.create()

        CommunityAdminFactory.create(user=self.profile.user,
                                     community=self.profile.community)

        # Create a Cyclos account for the 'member_profile'.
        self.cyclos_account = CyclosAccountFactory.create(
            cc3_profile=self.member_profile)
Esempio n. 21
0
    def setUp(self):
        set_backend(DummyCyclosBackend())

        self.group_1 = CyclosGroupFactory.create(initial=True)
        self.group_2 = CyclosGroupFactory.create()
        self.group_3 = CyclosGroupFactory.create()
        self.groupset = CyclosGroupSetFactory.create(
            groups=[self.group_1, self.group_2, self.group_3])

        self.community = CC3CommunityFactory.create(
            groupsets=[self.groupset], code='TST')
        if 'cc3.rewards' in settings.INSTALLED_APPS:
            self.defaultgoodcause = DefaultGoodCauseUserFactory.create(
                community=self.community
            )
        self.reg_code = CommunityRegistrationCodeFactory.create(code="I",
            community=self.community, groupset=self.groupset)

        self.user = UserFactory.create()
        self.profile = CC3ProfileFactory.create(community=self.community)
        self.terminal_1 = TerminalFactory.create(business=self.profile.user)
        self.token_1 = Token.objects.create(user=self.profile.user)
        self.operator_1 = OperatorFactory(business=self.profile.user)

        self.client = self.client_class(HTTP_AUTHORIZATION='Token {0}'.format(
            self.token_1.key))

        # Invalid user (does not have any CC3Profile related, no business
        # available then).
        self.terminal_2 = TerminalFactory.create(business=self.user)
        self.token_2 = Token.objects.create(user=self.user)
        self.operator_2 = OperatorFactory(business=self.user)
        self.client_bad = self.client_class(
            HTTP_AUTHORIZATION='Token {0}'.format(self.token_2.key))

        self.card_number = CardNumberFactory.create(number='12345')
        self.url = reverse(
            'api_cards_card_new_account_detail', args=[
                self.card_number.uid_number])
    def test_auth(self):
        """
        check authenticated users can access invoice views
        """
        admin_user_1 = UserFactory.create(
            is_staff=True, is_active=True, is_superuser=True)
        cyclos_group_1 = CyclosGroupFactory.create(
            initial=True, invoice_user=admin_user_1)
        cyclos_groupset_1 = CyclosGroupSetFactory.create(
            groups=[cyclos_group_1])
        community_1 = CC3CommunityFactory.create(groupsets=[cyclos_groupset_1])
        profile = AuthUserProfileFactory.create(
             web_payments_enabled=True, community=community_1)
        profile2 = AuthUserProfileFactory.create(
             web_payments_enabled=True, community=community_1)
        self.client.login(
            username=profile.user.username,
            password='******',
        )

        invoice = InvoiceFactory.create(
            from_user=profile.user,
            to_user=profile2.user
        )
        response = self.client.get(
            reverse('invoice_list'), follow=True)
        self.assertEqual(response.status_code, 200)

        # excel invoice download NotImplementedError
#        response = self.client.get(
#            reverse('invoice_download_excel', args=[invoice.pk, ]),
#            follow=True)
#        self.assertRaises(response, NotImplementedError)

        response = self.client.get(
            reverse('invoice_download_pdf', args=[invoice.pk, ]),
            follow=True)
        self.assertEqual(response.status_code, 200)