コード例 #1
0
    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])
コード例 #2
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()
コード例 #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)
        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})
コード例 #4
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})
コード例 #5
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)
コード例 #6
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})
コード例 #7
0
    def setUp(self):
        self.factory = RequestFactory()
        self.permission_class = IsAdManager()

        self.owner_profile = CC3ProfileFactory.create()
        self.member_profile = CC3ProfileFactory.create()

        self.ad = AdFactory.create(created_by=self.owner_profile)
コード例 #8
0
    def setUp(self):
        self.url = reverse('communityadmin_ns:transactions')

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

        CommunityAdminFactory.create(user=self.profile.user,
                                     community=self.profile.community)
コード例 #9
0
 def setUp(self):
     self.cyclos_group = CyclosGroupFactory.create()
     self.cc3_profile1 = CC3ProfileFactory.create(
         cyclos_group=self.cyclos_group)
     self.cc3_profile2 = CC3ProfileFactory.create(
         cyclos_group=self.cyclos_group)
     self.user1 = self.cc3_profile1.user
     self.user2 = self.cc3_profile2.user
コード例 #10
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)
        }
コード例 #11
0
    def setUp(self):
        self.factory = RequestFactory()
        self.permission_class = IsCommunityAdmin()

        self.admin_profile = CC3ProfileFactory.create()
        self.member_profile = CC3ProfileFactory.create()

        CommunityAdminFactory.create(user=self.admin_profile.user,
                                     community=self.admin_profile.community)
コード例 #12
0
    def setUp(self):
        self.profile_1 = CC3ProfileFactory.create()
        self.profile_2 = CC3ProfileFactory.create()
        self.form = TradeQoinPayDirectForm(user=self.profile_1.user)

        self.form.cleaned_data = {
            'amount': Decimal('10'),
            'contact_name': self.profile_2.full_name,
            'profile': self.profile_2,
            'description': 'Testing payments form.'
        }

        activate('en')
コード例 #13
0
    def setUp(self):
        group_1 = CyclosGroupFactory.create()
        group_2 = CyclosGroupFactory.create()
        group_3 = CyclosGroupFactory.create()
        self.groupset = CyclosGroupSetFactory.create(
            groups=[group_1, group_2, group_3])

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

        CommunityAdminFactory.create(user=self.profile.user,
                                     community=self.profile.community)
コード例 #14
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()
コード例 #15
0
    def test_auto_assign_terminal_product_reassignment(self):
        """Tests terminal rental product assignment is auto-updated when Terminal reassigned"""
        # should auto-create an AP
        term1 = TerminalFactory(business=self.cc3_profile.user)
        # should create an AP with qty 1
        self.assertEqual(
            1,
            self.cc3_profile.assigned_products.get(
                product=self.terminal_rental_product).quantity)
        term2 = TerminalFactory(business=self.cc3_profile.user)
        # should update qty to 2 -- re-get the AP to see if it has
        self.assertEqual(
            2,
            self.cc3_profile.assigned_products.get(
                product=self.terminal_rental_product).quantity)

        # now reassign one of the Terminals to someone else
        new_profile = CC3ProfileFactory.create(cyclos_group=self.cyclos_group)
        self.assertEqual(
            0,
            new_profile.assigned_products.filter(
                product=self.terminal_rental_product).count())

        term1.business = (new_profile.user)
        term1.save()

        # should both have APs, each with quantity 1
        self.assertEqual(
            1,
            self.cc3_profile.assigned_products.get(
                product=self.terminal_rental_product).quantity)
        self.assertEqual(
            1,
            new_profile.assigned_products.get(
                product=self.terminal_rental_product).quantity)
コード例 #16
0
    def setUp(self):
        self.profile = CC3ProfileFactory.create()

        self.factory = RequestFactory()

        self.request = self.factory.get('/')
        self.request.user = self.profile.user
コード例 #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)
コード例 #18
0
    def setUp(self):
        self.cyclos_group = CyclosGroupFactory.create()
        self.cc3_profile = CC3ProfileFactory.create(
            cyclos_group=self.cyclos_group)

        self.today = date.today()
        self.tomorrow = date.today() + timedelta(days=1)
コード例 #19
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])
コード例 #20
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()
コード例 #21
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)
コード例 #22
0
    def test_failed_donation_user_not_committed(self):
        """
        Tests a failed donation when the user is not committed with any cause.
        """
        # Create new user, not related with any cause.
        consumer = CC3ProfileFactory.create()
#        default_good_cause = DefaultGoodCauseUserFactory.create(
#            community=consumer.community
#        )

        transaction = cause_reward(100, consumer.user, 1)

        self.assertIsNone(transaction)
コード例 #23
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)
コード例 #24
0
    def test_registration_choice_validation_error(self, mock):
        """
        Tests ``ValidationError`` raised if the user is not able to get a card.
        """
        # Mock the `can_order_card()` method to always return `False`.
        mock.return_value = False

        profile = CC3ProfileFactory.create()
        form = OwnerRegisterCardForm(profile)
        form.cleaned_data = {'registration_choice': 'Send'}

        self.assertRaisesMessage(
            ValidationError,
            _('Please fill in the necessary information in your profile for '
              'direct debit'),
            form.clean_registration_choice)
コード例 #25
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
        }
コード例 #26
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()
コード例 #27
0
    def setUp(self):
        self.today = date.today()
        self.tomorrow = date.today() + timedelta(days=1)

        self.cyclos_group = CyclosGroupFactory.create()
        self.cc3_profile = CC3ProfileFactory.create(
            cyclos_group=self.cyclos_group)
        self.tax_regime = TaxRegime.objects.create(name="Big tax", percent=50)
        self.product = ProductFactory.create(tax_regime=self.tax_regime,
                                             max_discount_percent=25)
        self.terminal_qty_product = ProductFactory.create(
            auto_qty_type=AUTO_QTY_TYPE_TERMINALS)
        self.terminal_qty_product.user_groups.add(self.cyclos_group)
        self.terminal_qty_minus_one_product = ProductFactory.create(
            auto_qty_type=AUTO_QTY_TYPE_TERMINALS_MINUS_ONE)
        self.terminal_qty_minus_one_product.user_groups.add(self.cyclos_group)
        self.terminal_rental_product = ProductFactory.create(
            auto_assign_type=AUTO_ASSIGN_TYPE_TERMINAL_RENTAL,
            auto_qty_type=AUTO_QTY_TYPE_TERMINALS)
        self.terminal_rental_product.user_groups.add(self.cyclos_group)
コード例 #28
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])
コード例 #29
0
 def setUp(self):
     self.profile = CC3ProfileFactory.create()
     self.user_cause = UserCauseFactory.create(consumer=self.profile.user)
コード例 #30
0
 def setUp(self):
     self.profile = CC3ProfileFactory.create()
     self.user_cause = UserCauseFactory.create(consumer=self.profile.user)
     self.url = reverse('causes_list')