Created
March 6, 2012 23:04
-
-
Save juliomistral/1989633 to your computer and use it in GitHub Desktop.
Unit test review
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from unittest import TestCase | |
from checkoutservice.tests.base import FREE_USER_SUB | |
from checkoutservice.tests.base import ACTIVE_SILVER_P1Y_SUB | |
from checkoutservice.tests.base import ACTIVE_BRONZE_P1Y_SUB | |
from checkoutservice.tests.base import EXPIRED_BRONZE_P1Y_SUB | |
from checkoutservice.tests.base import EXPIRED_SILVER_P1Y_SUB | |
from checkoutservice.subscription.process import _determine_current_bundle | |
class TestSubscriptionProcess(TestCase): | |
def _generate_subscription_dict(self, subscription_roles): | |
subscriptions = {} | |
for sub in subscription_roles: | |
subscriptions.update(sub) | |
return subscriptions | |
def test_current_bundle_with_only_current_silver(self): | |
subscriptions = self._generate_subscription_dict([ACTIVE_SILVER_P1Y_SUB,]) | |
current_sub = _determine_current_bundle(subscriptions) | |
self.assertEquals( | |
current_sub['type'], | |
'silver', | |
'Did not return SILVER as the current bundle subscription: %s' % current_sub['type'] | |
) | |
def test_current_bundle_with_only_current_bronze(self): | |
subscriptions = self._generate_subscription_dict([ACTIVE_BRONZE_P1Y_SUB,]) | |
current_sub = _determine_current_bundle(subscriptions) | |
self.assertEquals( | |
current_sub['type'], | |
'bronze', | |
'Did not return BRONZE as the current bundle subscription: %s' % current_sub['type'] | |
) | |
def test_current_bundle_with_only_expired_silver(self): | |
subscriptions = self._generate_subscription_dict([EXPIRED_SILVER_P1Y_SUB,]) | |
current_sub = _determine_current_bundle(subscriptions) | |
self.assertEquals( | |
current_sub['type'], | |
'silver', | |
'Did not return SILVER as the current bundle subscription: %s' % current_sub['type'] | |
) | |
def test_current_bundle_with_only_expired_bronze(self): | |
subscriptions = self._generate_subscription_dict([EXPIRED_BRONZE_P1Y_SUB,]) | |
current_sub = _determine_current_bundle(subscriptions) | |
self.assertEquals( | |
current_sub['type'], | |
'bronze', | |
'Did not return BRONZE as the current bundle subscription: %s' % current_sub['type'] | |
) | |
def test_current_bundle_with_both_active_silver_and_bronze(self): | |
subscriptions = self._generate_subscription_dict([ACTIVE_SILVER_P1Y_SUB, ACTIVE_BRONZE_P1Y_SUB,]) | |
current_sub = _determine_current_bundle(subscriptions) | |
self.assertEquals( | |
current_sub['type'], | |
'silver', | |
'Did not return SILVER as the current bundle subscription: %s' % current_sub['type'] | |
) | |
def test_current_bundle_with_active_silver_and_expired_bronze(self): | |
subscriptions = self._generate_subscription_dict([ACTIVE_SILVER_P1Y_SUB, EXPIRED_BRONZE_P1Y_SUB,]) | |
current_sub = _determine_current_bundle(subscriptions) | |
self.assertEquals( | |
current_sub['type'], | |
'silver', | |
'Did not return SILVER as the current bundle subscription: %s' % current_sub['type'] | |
) | |
def test_current_bundle_with_expired_silver_and_active_bronze(self): | |
subscriptions = self._generate_subscription_dict([EXPIRED_SILVER_P1Y_SUB, ACTIVE_BRONZE_P1Y_SUB, ]) | |
current_sub = _determine_current_bundle(subscriptions) | |
self.assertEquals( | |
current_sub['type'], | |
'bronze', | |
'Did not return BRONZE as the current bundle subscription: %s' % current_sub['type'] | |
) | |
def test_current_bundle_with_expired_silver_and_bronze(self): | |
subscriptions = self._generate_subscription_dict([EXPIRED_SILVER_P1Y_SUB, EXPIRED_BRONZE_P1Y_SUB, ]) | |
current_sub = _determine_current_bundle(subscriptions) | |
self.assertEquals( | |
current_sub['type'], | |
'silver', | |
'Did not return SILVER as the current bundle subscription: %s' % current_sub['type'] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment