Exemplo n.º 1
0
class TestCommunity(unittest.TestCase):
    """ Test the Maker model. """

    def setUp(self):
        """ Setup Tests """
        self.community = Community(
            name='Test Community',
            slug=Community.get_slug_for_name('Test_Community')
            )

        self.community.put()

        self.maker = Maker(community=self.community,
                           store_name="Test Store",
                           store_description='A test store',
                           full_name="Tina Test",
                           email='*****@*****.**',
                           paypal_business_account_email = "*****@*****.**",
                           phone_number = "530111121",
                           location = "Right Here",
                           mailing_address = "111 Test Lane, Testable, CA 95945",
                           approval_status = 'Approved',
                           tags=['test', 'testy', 'testiferous'])
        self.maker.put()


    def tearDown(self):
        self.maker.delete()
        self.community.delete()

    def testEmailValidation(self):
        try:
            self.maker.paypal_business_account_email = "*****@*****.**"
            self.maker.put()
            self.maker.paypal_business_account_email = "*****@*****.**"
            self.maker.put()
            self.maker.paypal_business_account_email = "*****@*****.**"
            self.maker.put()
            self.maker.paypal_business_account_email = "*****@*****.**"
            self.maker.put()
            self.maker.paypal_business_account_email = "*****@*****.**"
            self.maker.put()
        except db.BadValueError:
            self.fail('Threw exception for good email address: ' + self.maker.paypal_business_account_email)

        try:
            self.maker.paypal_business_account_email = "thisshouldfail"
            self.maker.put()
            self.maker.paypal_business_account_email = "badexample.com"
            self.maker.put()            
            self.maker.paypal_business_account_email = "*****@*****.**"
            self.maker.put()
            self.maker.paypal_business_account_email = "bad@example_host.com"
            self.maker.put()            
        except db.BadValueError:
            # We expect an exception, this is success
            return

        self.fail('Failed to throw exception for bad email address: ' + self.maker.paypal_business_account_email)
Exemplo n.º 2
0
class TestCommunity(unittest.TestCase):
    """ Test the Community model. """

    def setUp(self):
        """ Setup Tests """
        self.community = Community(name='Test Community',
                                   slug=Community.get_slug_for_name('Test_Community'),
                                   use_sandbox=True,
                                   fee_percentage=10.0,
                                   fee_minimum=0.3,
                                   paypal_fee_percentage=2.9,
                                   paypal_fee_minimum=0.3,
                                   paypal_sandbox_business_id = '*****@*****.**',
                                   paypal_sandbox_email_address = '*****@*****.**',
                                   paypal_sandbox_api_username = '******',
                                   paypal_sandbox_api_password = '******',
                                   paypal_sandbox_api_signature = 'sand_api_sig',
                                   paypal_sandbox_application_id = 'sand_api_app_id',
                                   paypal_business_id = '*****@*****.**',
                                   paypal_email_address = '*****@*****.**',
                                   paypal_api_username = '******',
                                   paypal_api_password = '******',
                                   paypal_api_signature = 'api_sig',
                                   paypal_application_id = 'api_app_id',
                                   )
        self.community.put()

    def tearDown(self):
        memcache.flush_all()
        self.community.delete()

    def testSlugs(self):
        name = 'name with a space'
        slug = Community.get_slug_for_name(name)
        self.assertTrue(slug == 'name-with-a-space')

    def testAdImpressions(self):
        advertisement = Advertisement(name='Test')
        advertisement.put()
        self.assertTrue(advertisement.remaining_impressions() == 0)
        advertisement.refill_impressions(10000)
        self.assertTrue(advertisement.remaining_impressions() == 10000)
        advertisement.decrement_impressions()
        advertisement.decrement_impressions()
        self.assertTrue(advertisement.remaining_impressions() == 9998)

    def testCredentials(self):
        self.community.use_sandbox = True
        self.assertTrue(self.community.business_id == self.community.paypal_sandbox_business_id)
        self.assertTrue(self.community.email_address == self.community.paypal_sandbox_email_address)
        self.assertTrue(self.community.api_username == self.community.paypal_sandbox_api_username)
        self.assertTrue(self.community.api_password == self.community.paypal_sandbox_api_password)
        self.assertTrue(self.community.api_signature == self.community.paypal_sandbox_api_signature)
        self.assertTrue(self.community.application_id == self.community.paypal_sandbox_application_id)

        self.community.use_sandbox = False
        self.assertTrue(self.community.business_id == self.community.paypal_business_id)
        self.assertTrue(self.community.email_address == self.community.paypal_email_address)
        self.assertTrue(self.community.api_username == self.community.paypal_api_username)
        self.assertTrue(self.community.api_password == self.community.paypal_api_password)
        self.assertTrue(self.community.api_signature == self.community.paypal_api_signature)
        self.assertTrue(self.community.application_id == self.community.paypal_application_id)