Exemplo 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)
        }
Exemplo n.º 2
0
    def setUp(self):
        set_backend(DummyCyclosBackend())

        self.login_url = reverse('api_files_login')
        self.url = reverse('api_files_upload')

        self.user_1 = UserFactory.create()
        self.file_service_user_1 = FileServiceUserFactory.create(
            user=self.user_1)

        # user to check permissions - ie no FileServiceUser for this user
        self.user_no_file_service_user = UserFactory.create()

        self.user_2 = UserFactory.create()
        self.file_service_user_2 = FileServiceUserFactory.create(
            user=self.user_2, ip_addresses=u'testserver')

        self.user_3 = UserFactory.create()
        self.file_service_user_3 = FileServiceUserFactory.create(
            user=self.user_3, ip_addresses=u'9.9.9.9:1234')

        self.format_1 = FormatFactory.create(description="CSV file",
                                             mime_type="csv",
                                             extension="csv")
        self.file_type_1_description = u'huurcontract'
        self.file_type_1 = FileTypeFactory.create(
            description=self.file_type_1_description,
            format=self.format_1,
            process_model=None)

        # Create a CSV file.
        self.csv_file = StringIO()
        self.csv_file.write('1A2B3C4D,12354\n3D4BFF54,90023\n9A6542BD,43021')
        self.csv_file.name = u'huurcontract.csv'
Exemplo 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)
Exemplo n.º 4
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)
    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])
Exemplo n.º 6
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)
Exemplo n.º 7
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})
Exemplo n.º 8
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})
Exemplo n.º 9
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')
Exemplo n.º 10
0
    def setUp(self):
        self.backend = DummyCyclosBackend()
        set_backend(self.backend)

        # Disconnect ``link_account`` signal.
        post_save.disconnect(
            receiver=link_account, sender=CC3Profile,
            dispatch_uid='cc3_qoin_profile_save')

        self.user = UserFactory.create()
        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.profile = CC3ProfileFactory.create(community=self.community)

        self.negative_balance_email = MailMessageFactory.create(
            type=MAIL_TYPE_NEGATIVE_BALANCE_USER,
            subject="Negative balance USER(NEG)")
        self.negative_balance_email_admins = MailMessageFactory.create(
            type=MAIL_TYPE_NEGATIVE_BALANCE_ADMINS,
            subject="Negative balance ADMIN(NEG)")
        self.negative_balance_collect_email = MailMessageFactory.create(
            type=MAIL_TYPE_NEGATIVE_BALANCE_COLLECT_USER,
            subject="Negative balance USER(COLLECT)")
        self.negative_balance_collect_email_admins = MailMessageFactory.create(
            type=MAIL_TYPE_NEGATIVE_BALANCE_COLLECT_ADMINS,
            subject="Negative balance ADMIN(COLLECT)")
        self.large_balance_email = MailMessageFactory.create(
            type=MAIL_TYPE_LARGE_BALANCE_USER,
            subject="Large balance USER(LARGE)")
        self.large_balance_email_admins = MailMessageFactory.create(
            type=MAIL_TYPE_LARGE_BALANCE_ADMINS,
            subject="Large balance ADMIN(LARGE)")
Exemplo n.º 11
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])
Exemplo n.º 12
0
    def setUp(self):
        set_backend(DummyCyclosBackend())

        self.good_cause = CharityProfileFactory.create()
        self.business = BusinessProfileFactory.create()
        MailMessage.objects.all().delete()  # why is this needed??
        self.invoice_email = MailMessageFactory.create(
            type=MAIL_TYPE_MONTHLY_INVOICE, subject="Monthly invoice")
Exemplo n.º 13
0
    def setUp(self):
        set_backend(DummyCyclosBackend())

        self.user = CC3ProfileFactory.create()
        self.cause = CC3ProfileFactory.create()

        self.url = reverse(
            'join_cause', kwargs={'cause_pk': self.cause.user.pk})
Exemplo n.º 14
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)
Exemplo n.º 15
0
    def setUp(self):
        set_backend(DummyCyclosBackend())

        self.profile = CC3ProfileFactory.create()
        self.price_option = AdPricingOptionFactory.create(title='TBD')

        self.ad_1 = AdFactory.create(price='10.0',
                                     created_by=self.profile,
                                     status=AD_STATUS_ACTIVE)
        self.ad_2 = AdFactory.create(created_by=self.profile,
                                     price_option=self.price_option)
Exemplo n.º 16
0
    def setUp(self):
        self.backend = DummyCyclosBackend()
        set_backend(self.backend)

        self.consumer = CC3ProfileFactory.create()
        self.cause = CC3ProfileFactory.create()

        self.user_cause = UserCauseFactory.create(
            consumer=self.consumer.user, cause=self.cause.user)

        self.consumer.community.min_donation_percent = 20
        self.consumer.community.max_donation_percent = 60
        self.consumer.community.default_donation_percent = 40
        self.consumer.community.save()
Exemplo n.º 17
0
    def setUp(self):
        set_backend(DummyCyclosBackend())

        self.profile_1 = CC3ProfileFactory.create()
        self.profile_2 = CC3ProfileFactory.create()

        self.price_option = AdPricingOptionFactory.create(title='TBD')
        self.ad_active = AdFactory.create(price='10.0',
                                          status=AD_STATUS_ACTIVE,
                                          created_by=self.profile_1)
        self.ad_disabled = AdFactory.create(price='10.0',
                                            status=AD_STATUS_DISABLED,
                                            created_by=self.profile_1)
        self.ad_onhold = AdFactory.create(price='10.0',
                                          status=AD_STATUS_ONHOLD,
                                          created_by=self.profile_1)
Exemplo n.º 18
0
    def setUp(self):
        set_backend(DummyCyclosBackend())

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

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

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

        self.member_1 = CC3ProfileFactory.create(
            community=self.profile.community)
        self.member_2 = CC3ProfileFactory.create()
        self.member_3 = CC3ProfileFactory.create()

        self.factory = RequestFactory()
Exemplo n.º 19
0
    def setUp(self):
        set_backend(DummyCyclosBackend())

        self.ad = AdFactory.create()
        self.user = UserFactory.create(first_name='Vanessa',
                                       last_name='Gaultier',
                                       username='******',
                                       email='*****@*****.**')
        self.profile = CC3ProfileFactory.create(user=self.user)

        self.form = MarketplacePayForm(user=self.profile.user)
        self.test_data = {
            'amount': 10.0,
            'contact_name': 'Vanessa Gaultier',
            'description': 'Testing payment',
            'ad': self.ad.pk
        }
Exemplo n.º 20
0
    def setUp(self):
        set_backend(DummyCyclosBackend())

        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.user_2 = UserFactory.create()
        self.cc3profile_2 = CC3ProfileFactory.create(user=self.user_2,
                                                     first_name='Test',
                                                     last_name='User')

        self.client = self.client_class(HTTP_AUTHORIZATION='Token {0}'.format(
            self.token_1.key))
        self.card_2 = CardFactory.create(owner=self.user_2)
        self.blocked_card = CardFactory.create(owner=self.user_2)
        self.blocked_card.block_card()
Exemplo n.º 21
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()
Exemplo n.º 22
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',
        )
Exemplo n.º 23
0
    def setUp(self):
        self.backend = DummyCyclosBackend()
        set_backend(self.backend)

        # Initialize Cyclos groups and groupsets for communities.
        admin_user = UserFactory.create(
            is_staff=True, is_active=True, is_superuser=True)
        self.cyclos_group = CyclosGroupFactory.create(
            initial=True, invoice_user=admin_user)
        cyclos_groupset = CyclosGroupSetFactory.create(
            groups=[self.cyclos_group])
        community = CC3CommunityFactory.create(groupsets=[cyclos_groupset])

        self.profile_1 = CC3ProfileFactory.create(
            web_payments_enabled=True, community=community)
        self.profile_2 = CC3ProfileFactory.create(
            web_payments_enabled=True, community=community)

        # Create the ``CyclosAccount``, with all the groups + groupsets ready.
        self.cyclos_account = CyclosAccountFactory.create(
            cc3_profile=self.profile_1)
Exemplo n.º 24
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])
Exemplo n.º 25
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)
Exemplo n.º 26
0
class CardPaymentTest(TestCase):
    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])

    def test_card_pay_successful(self):
        """ Test a payment from a user/card-holder to the business owner """
        data = {
            'terminal_name': self.terminal_1.name,
            'operator_name': self.operator_1.name,
            'sender_id': self.card_2.owner.id,
            'receiver_id': self.operator_1.business.id,
            'amount': '50',
            'description': 'My transaction'
        }

        response = self.client.post(
            self.url, data=json.dumps(data), content_type='application/json')
        self.assertEqual(response.status_code, HTTP_200_OK)
        data = json.loads(response.content)
        self.assertEqual(data['transaction_id'],
                         self.backend.transactions()[0].transfer_id)
        trans = self.backend.transactions()[0]
        self.assertEqual(trans.amount, 50)
        self.assertEqual(trans.sender, self.card_2.owner)
        self.assertEqual(trans.recipient, self.operator_1.business)
        self.assertEqual(trans.description, 'My transaction')

    def test_card_pay_successful_decimal(self):
        """ Test a decimal payment from a user/card-holder to business owner """
        data = {
            'terminal_name': self.terminal_1.name,
            'operator_name': self.operator_1.name,
            'sender_id': self.card_2.owner.id,
            'receiver_id': self.operator_1.business.id,
            'amount': '40.01',
            'description': 'My transaction'
        }

        response = self.client.post(
            self.url, data=json.dumps(data), content_type='application/json')
        self.assertEqual(response.status_code, HTTP_200_OK)
        data = json.loads(response.content)
        self.assertEqual(data['transaction_id'],
                         self.backend.transactions()[0].transfer_id)
        trans = self.backend.transactions()[0]
        self.assertEqual(trans.amount, Decimal('40.01'))
        self.assertEqual(trans.sender, self.card_2.owner)
        self.assertEqual(trans.recipient, self.operator_1.business)
        self.assertEqual(trans.description, 'My transaction')

    def test_card_payment_operator_name_business_unique_together(self):
        """
        Test a payment operation when there is more than one ``Operator``
        object with the same ``name`` defined.

        Enforces the checkup of the 'unique together' relationship of the two
        fields in the ``Operator`` model, which is used in the API view
        ``CardTransactionView`` to retrieve the operator.
        """
        OperatorFactory(name=self.operator_1.name)
        data = {
            'terminal_name': self.terminal_1.name,
            'operator_name': self.operator_1.name,
            'sender_id': self.card_2.owner.id,
            'receiver_id': self.operator_1.business.id,
            'amount': '50',
            'description': 'My transaction'
        }

        response = self.client.post(
            self.url, data=json.dumps(data), content_type='application/json')
        self.assertEqual(response.status_code, HTTP_200_OK)

    def test_card_receive(self):
        """ Test a payment from the business owner to the user/card-holder """
        data = {
            'terminal_name': self.terminal_1.name,
            'operator_name': self.operator_1.name,
            'receiver_id': self.card_2.owner.id,
            'sender_id': self.operator_1.business.id,
            'amount': '50',
            'description': 'My transaction'
        }
        response = self.client.post(
            self.url, data=json.dumps(data), content_type='application/json')
        self.assertEqual(response.status_code, HTTP_200_OK)
        data = json.loads(response.content)
        self.assertEqual(data['transaction_id'],
                         self.backend.transactions()[0].transfer_id)
        trans = self.backend.transactions()[0]
        self.assertEqual(trans.amount, 50)
        self.assertEqual(trans.recipient, self.card_2.owner)
        self.assertEqual(trans.sender, self.operator_1.business)
        self.assertEqual(trans.description, 'My transaction')

    def test_card_receive_credit_limit(self):
        """ Test a payment from the business owner to the user/card-holder,
        where the balance of the business owner can become negative
        (DummyCyclosBackend credit limit: 50) """
        data = {
            'terminal_name': self.terminal_1.name,
            'operator_name': self.operator_1.name,
            'receiver_id': self.card_2.owner.id,
            'sender_id': self.operator_1.business.id,
            'amount': '149',
            'description': 'My transaction'
        }
        response = self.client.post(
            self.url, data=json.dumps(data), content_type='application/json')
        self.assertEqual(response.status_code, HTTP_200_OK)
        data = json.loads(response.content)
        self.assertEqual(data['transaction_id'],
                         self.backend.transactions()[0].transfer_id)
        trans = self.backend.transactions()[0]
        self.assertEqual(trans.amount, 149)
        self.assertEqual(trans.recipient, self.card_2.owner)
        self.assertEqual(trans.sender, self.operator_1.business)
        self.assertEqual(trans.description, 'My transaction')

    def test_card_receive_credit_limit_invalid(self):
        """ Test a payment from the business owner to the user/card-holder,
        where the credit limit of the business owner is invalid.
        (DummyCyclosBackend credit limit: 50) """
        data = {
            'terminal_name': self.terminal_1.name,
            'operator_name': self.operator_1.name,
            'receiver_id': self.card_2.owner.id,
            'sender_id': self.operator_1.business.id,
            'amount': '151',
            'description': 'My transaction'
        }
        response = self.client.post(
            self.url, data=json.dumps(data), content_type='application/json')
        self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST)

    def test_card_pay_invalid_terminal(self):
        """ Wrong terminal name """
        data = {
            'terminal_name': 'invalid',
            'operator_name': self.operator_1.name,
            'sender_id': self.card_2.owner.id,
            'receiver_id': self.operator_1.business.id,
            'amount': '50',
            'description': 'My transaction'
        }

        response = self.client.post(
            self.url, data=json.dumps(data), content_type='application/json')
        self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST)

    def test_card_pay_invalid_operator(self):
        """ Wrong operator name """
        data = {
            'terminal_name': self.terminal_1.name,
            'operator_name': 'invalid',
            'sender_id': self.card_2.owner.id,
            'receiver_id': self.operator_1.business.id,
            'amount': '50',
            'description': 'My transaction'
        }

        response = self.client.post(
            self.url, data=json.dumps(data), content_type='application/json')
        self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST)

    def test_card_pay_third_party_payment(self):
        """
        Unable to perform payments if we're not one of either party.
        Note that we authenticate with terminal_1/operator_1
        """
        data = {
            'terminal_name': self.terminal_4.name,
            'operator_name': self.operator_4.name,
            'sender_id': self.card_2.owner.id,
            'receiver_id': self.operator_4.business.id,
            'amount': '50',
            'description': 'My transaction'
        }

        response = self.client.post(
            self.url, data=json.dumps(data), content_type='application/json')
        self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST)

    def test_card_pay_same_sender_receiver(self):
        """ Can't send payments if the user is both sender and receiver """
        data = {
            'terminal_name': self.terminal_1.name,
            'operator_name': self.operator_1.name,
            'sender_id': self.card_2.owner.id,
            'receiver_id': self.card_2.owner.id,
            'amount': '50',
            'description': 'My transaction'
        }

        response = self.client.post(
            self.url, data=json.dumps(data), content_type='application/json')
        self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST)

    def test_card_pay_wrong_card(self):
        """ The payment must be made on the correct card resource """
        data = {
            'terminal_name': self.terminal_1.name,
            'operator_name': self.operator_1.name,
            'sender_id': self.card_3.owner.id,
            'receiver_id': self.operator_1.business.id,
            'amount': '50',
            'description': 'My transaction'
        }

        response = self.client.post(
            self.url, data=json.dumps(data), content_type='application/json')
        self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST)

    def test_card_pay_from_blocked_card(self):
        """ The payment must be from a non-blocked card """
        data = {
            'terminal_name': self.terminal_1.name,
            'operator_name': self.operator_1.name,
            'sender_id': self.blocked_card.owner.id,
            'receiver_id': self.card_2.owner.id,
            'amount': '50',
            'description': 'My transaction'
        }
        url = reverse(
            'api_cards_card_payment', args=[self.blocked_card.number.uid_number])

        response = self.client.post(
            self.url, data=json.dumps(data), content_type='application/json')
        self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST)

    @override_settings(INTER_COMMUNITIES_TRANSACTIONS=False)
    def test_card_pay_inter_community_not_possible(self):
        """ Testing INTER_COMMUNITIES_TRANSACTIONS=False blocks """
        data = {
            'terminal_name': self.terminal_1.name,
            'operator_name': self.operator_1.name,
            'sender_id': self.card_5.owner.id,
            'receiver_id': self.operator_1.business.id,
            'amount': '50',
            'description': 'My transaction'
        }
        response = self.client.post(
            self.url, data=json.dumps(data), content_type='application/json')
        self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST)

    @override_settings(INTER_COMMUNITIES_TRANSACTIONS=True)
    def test_card_pay_inter_community_possible(self):
        """ Testing INTER_COMMUNITIES_TRANSACTIONS=True allows """
        data = {
            'terminal_name': self.terminal_1.name,
            'operator_name': self.operator_1.name,
            'sender_id': self.card_2.owner.id,
            'receiver_id': self.operator_1.business.id,
            'amount': '50',
            'description': 'My transaction'
        }
        response = self.client.post(
            self.url, data=json.dumps(data), content_type='application/json')
        self.assertEqual(response.status_code, HTTP_200_OK)
Exemplo n.º 27
0
class CardRewardTest(TestCase):
    """
    Test case for the ``CardRewardView`` API view.

    Rewards must be performed by following this schema:

    1 - The business transfers the reward amount to the consumer.
    2 - A fixed percentage (by default the 40%) of that amount is deducted
    for the consumer cause.
    3 - The consumer transfers that percentage of the reward amount to the
    cause.

    Then, two transactions must be performed and also logged to the system.
    """
    @skipIf(not 'cc3.rewards' in settings.INSTALLED_APPS,
            u'Skipped as cc3.rewards app not enabled')
    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)
        }

    @skipIf(not 'cc3.rewards' in settings.INSTALLED_APPS,
            u'Skipped as cc3.rewards app not enabled')
    @override_settings(INTER_COMMUNITIES_TRANSACTIONS=True)
    def test_card_reward_business_to_consumer_transaction(self):
        """
        Tests the transaction from business to consumer performed during a
        successful reward operation.
        """
        response = self.client.post(
            self.url, data=json.dumps(self.post_data),
            content_type='application/json')

        self.assertEqual(response.status_code, HTTP_200_OK)

        data = json.loads(response.content)

        self.assertEqual(data['card_transaction_id'],
                         self.backend.transactions()[0].transfer_id)

        # Check the transaction from business to consumer.
        trans = self.backend.transactions()[0]
        self.assertEqual(trans.amount, 100)
        self.assertEqual(trans.sender, self.terminal_1.business)
        self.assertEqual(trans.recipient, self.card_2.owner)
        self.assertEqual(trans.description, self.post_data['description'])

    @skipIf(not 'cc3.rewards' in settings.INSTALLED_APPS,
            u'Skipped as cc3.rewards app not enabled')
    @override_settings(INTER_COMMUNITIES_TRANSACTIONS=True)
    def test_card_reward_consumer_to_cause_transaction(self):
        """
        Tests the transaction from consumer to cause performed during a
        successful reward operation.
        """
        response = self.client.post(
            self.url, data=json.dumps(self.post_data),
            content_type='application/json')

        self.assertEqual(response.status_code, HTTP_200_OK)

        data = json.loads(response.content)

        self.assertEqual(data['reward_transaction_id'],
                         self.backend.transactions()[1].transfer_id)

        # Check the transaction from consumer to cause.
        # It must be the 40% of the initial transaction.
        trans = self.backend.transactions()[1]
        self.assertEqual(trans.amount, 40)
        self.assertEqual(trans.sender, self.card_2.owner)
        self.assertEqual(trans.recipient, self.user_cause.cause)
        self.assertEqual(trans.description, _('Cause donation'))

    @skipIf(not 'cc3.rewards' in settings.INSTALLED_APPS,
            u'Skipped as cc3.rewards app not enabled')
    @override_settings(INTER_COMMUNITIES_TRANSACTIONS=True)
    def test_card_reward_transaction_logged(self):
        """
        Tests the creation of ``Transaction`` objects to log the rewarding.

        There must be 2 ``Transaction``s logged: one from the business to the
        consumer and another one from the consumer to the cause.
        """
        response = self.client.post(
            self.url, data=json.dumps(self.post_data),
            content_type='application/json')

        self.assertEqual(response.status_code, HTTP_200_OK)

        transactions = CardTransaction.objects.all()
        self.assertEqual(len(transactions), 2)

    @skipIf(not 'cc3.rewards' in settings.INSTALLED_APPS,
            u'Skipped as cc3.rewards app not enabled')
    @override_settings(INTER_COMMUNITIES_TRANSACTIONS=True)
    def test_card_reward_invalid_terminal(self):
        """ Test wrong terminal name when performing a reward """
        self.post_data['terminal_name'] = 'invalid'

        response = self.client.post(
            self.url, data=json.dumps(self.post_data),
            content_type='application/json')
        self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST)

    @skipIf(not 'cc3.rewards' in settings.INSTALLED_APPS,
            u'Skipped as cc3.rewards app not enabled')
    @override_settings(INTER_COMMUNITIES_TRANSACTIONS=True)
    def test_card_reward_invalid_operator(self):
        """ Test wrong operator name when performing a reward """
        self.post_data['operator_name'] = 'invalid'

        response = self.client.post(
            self.url, data=json.dumps(self.post_data),
            content_type='application/json')
        self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST)

# TODO, test to check community and user values are used appropriately
    #@override_settings(INTER_COMMUNITIES_TRANSACTIONS=True,
    #                   REWARDS_FIXED_PERCENTAGE=None)
    #@skipIf(not 'cc3.rewards' in settings.INSTALLED_APPS,
    #        u'Skipped as cc3.rewards app not enabled')
    #def test_card_reward_fixed_percentage_setting(self):
    #    """
    #    Test automatic fallback when ``REWARDS_FIXED_PERCENTAGE`` setting is
    #    missing.
    #    """
    #    # Delete the setting.
    #    del settings.REWARDS_FIXED_PERCENTAGE
    #
    #    response = self.client.post(
    #        self.url, data=json.dumps(self.post_data),
    #        content_type='application/json')
    #
    #    self.assertEqual(response.status_code, HTTP_200_OK)
    #
    #    data = json.loads(response.content)
    #
    #    self.assertEqual(data['reward_transaction_id'],
    #                     self.backend.transactions()[1].transfer_id)
    #
    #    # Check the transaction from consumer to cause.
    #    # It must be the 40% of the initial transaction.
    #    trans = self.backend.transactions()[1]
    #    self.assertEqual(trans.amount, 40)
    #    self.assertEqual(trans.sender, self.card_2.owner)
    #    self.assertEqual(trans.recipient, self.user_cause.cause)
    #    self.assertEqual(trans.description, _('Cause donation'))

    @skipIf(not 'cc3.rewards' in settings.INSTALLED_APPS,
            u'Skipped as cc3.rewards app not enabled')
    @override_settings(INTER_COMMUNITIES_TRANSACTIONS=True)
    def test_card_reward_no_cause_available(self):
        """
        Tests that the request returns a 400 error when the user has no
        charity cause configured.
        """
        url = reverse(
            'api_cards_card_reward', args=[self.card_3.number.uid_number])

        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_3.owner.id,
            'amount': '100',
            'description': 'Reward to good cause {0}'.format(
                self.user_cause.cause)
        }

        response = self.client.post(
            url, data=json.dumps(post_data), content_type='application/json')

        self.assertEqual(response.status_code, HTTP_200_OK)

        data = json.loads(response.content)

        self.assertIsNone(data['reward_transaction_id'])

    @skipIf(not 'cc3.rewards' in settings.INSTALLED_APPS,
            u'Skipped as cc3.rewards app not enabled')
    @override_settings(INTER_COMMUNITIES_TRANSACTIONS=False)
    def test_card_reward_inter_community_fails(self):
        """
        Tests that the request returns a 400 error when the reward is attempted
        to a business and/or cause in a different community.

        NB this relies on the fact that all users in these
        tests are in different communities
        """
        url = reverse(
            'api_cards_card_reward', args=[self.card_3.number.uid_number])

        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_3.owner.id,
            'amount': '100',
            'description': 'Reward to good cause {0}'.format(
                self.user_cause.cause)
        }

        response = self.client.post(
            url, data=json.dumps(post_data), content_type='application/json')

        self.assertEqual(response.status_code, HTTP_400_BAD_REQUEST)