Example #1
0
class TestBango(Patcher, TestCase):
    fixtures = fixture('user_999')

    def setUp(self):
        super(TestBango, self).setUp()
        self.user = UserProfile.objects.filter()[0]
        self.app = app_factory()
        self.make_premium(self.app)

        self.seller = SolitudeSeller.objects.create(resource_uri='sellerres',
                                                    user=self.user)
        self.account = PaymentAccount.objects.create(
            solitude_seller=self.seller,
            user=self.user,
            name='paname',
            uri='acuri',
            inactive=False,
            seller_uri='selluri',
            account_id=123,
            provider=PROVIDER_BANGO)
        self.bango = Bango()

    def test_create(self):
        self.generic_patcher.product.get_object_or_404.return_value = {
            'resource_uri': 'gpuri'
        }
        self.bango_patcher.product.get_object_or_404.return_value = {
            'resource_uri': 'bpruri',
            'bango_id': 'bango#',
            'seller': 'selluri'
        }

        uri = self.bango.product_create(self.account, self.app)
        eq_(uri, 'bpruri')

    def test_create_new(self):
        self.bango_patcher.product.get_object_or_404.side_effect = (
            ObjectDoesNotExist)
        self.bango_p_patcher.product.post.return_value = {
            'resource_uri': '',
            'bango_id': 1
        }
        self.bango.product_create(self.account, self.app)
        ok_('packageId' in self.bango_p_patcher.product.post.call_args[1]
            ['data'])

    def test_terms_bleached(self):
        self.bango_patcher.sbi.agreement.get_object.return_value = {
            'text': '<script>foo</script><h3></h3>'
        }
        eq_(
            self.bango.terms_retrieve(Mock())['text'],
            u'&lt;script&gt;foo&lt;/script&gt;<h3></h3>')
Example #2
0
    def setUp(self):
        super(TestBango, self).setUp()
        self.user = UserProfile.objects.filter()[0]
        self.app = app_factory()
        self.make_premium(self.app)

        self.seller = SolitudeSeller.objects.create(
            resource_uri='sellerres', user=self.user
        )
        self.account = PaymentAccount.objects.create(
            solitude_seller=self.seller,
            user=self.user, name='paname', uri='acuri',
            inactive=False, seller_uri='selluri',
            account_id=123, provider=PROVIDER_BANGO
        )
        self.bango = Bango()
Example #3
0
class TestBango(Patcher, TestCase):
    fixtures = fixture('user_999')

    def setUp(self):
        super(TestBango, self).setUp()
        self.user = UserProfile.objects.filter()[0]
        self.app = app_factory()
        self.make_premium(self.app)

        self.seller = SolitudeSeller.objects.create(
            resource_uri='sellerres', user=self.user
        )
        self.account = PaymentAccount.objects.create(
            solitude_seller=self.seller,
            user=self.user, name='paname', uri='acuri',
            inactive=False, seller_uri='selluri',
            account_id=123, provider=PROVIDER_BANGO
        )
        self.bango = Bango()

    def test_create(self):
        self.generic_patcher.product.get_object_or_404.return_value = {
            'resource_uri': 'gpuri'}
        self.bango_patcher.product.get_object_or_404.return_value = {
            'resource_uri': 'bpruri', 'bango_id': 'bango#', 'seller': 'selluri'
        }

        uri = self.bango.product_create(self.account, self.app)
        eq_(uri, 'bpruri')

    def test_create_new(self):
        self.bango_patcher.product.get_object_or_404.side_effect = (
            ObjectDoesNotExist)
        self.bango_p_patcher.product.post.return_value = {
            'resource_uri': '', 'bango_id': 1
        }
        self.bango.product_create(self.account, self.app)
        ok_('packageId' in
            self.bango_p_patcher.product.post.call_args[1]['data'])

    def test_terms_bleached(self):
        self.bango_patcher.sbi.agreement.get_object.return_value = {
            'text': '<script>foo</script><h3></h3>'}
        eq_(self.bango.terms_retrieve(Mock())['text'],
            u'&lt;script&gt;foo&lt;/script&gt;<h3></h3>')
Example #4
0
class TestBango(Patcher, TestCase):
    fixtures = fixture("user_999")

    def setUp(self):
        super(TestBango, self).setUp()
        self.user = UserProfile.objects.filter()[0]
        self.app = app_factory()
        self.make_premium(self.app)

        self.seller = SolitudeSeller.objects.create(resource_uri="sellerres", user=self.user)
        self.account = PaymentAccount.objects.create(
            solitude_seller=self.seller,
            user=self.user,
            name="paname",
            uri="acuri",
            inactive=False,
            seller_uri="selluri",
            account_id=123,
            provider=PROVIDER_BANGO,
        )
        self.bango = Bango()

    def test_create(self):
        self.generic_patcher.product.get_object_or_404.return_value = {"resource_uri": "gpuri"}
        self.bango_patcher.product.get_object_or_404.return_value = {
            "resource_uri": "bpruri",
            "bango_id": "bango#",
            "seller": "selluri",
        }

        uri = self.bango.product_create(self.account, self.app)
        eq_(uri, "bpruri")

    def test_create_new(self):
        self.bango_patcher.product.get_object_or_404.side_effect = ObjectDoesNotExist
        self.bango_p_patcher.product.post.return_value = {"resource_uri": "", "bango_id": 1}
        self.bango.product_create(self.account, self.app)
        ok_("packageId" in self.bango_p_patcher.product.post.call_args[1]["data"])