Skip to content

Instantly share code, notes, and snippets.

@foxx
Created July 21, 2013 16:04
Show Gist options
  • Save foxx/6048955 to your computer and use it in GitHub Desktop.
Save foxx/6048955 to your computer and use it in GitHub Desktop.
# default sub orders before first sub end
with patch_today(2013, 1, 1, 1, 1, 1) as pt:
i = UserSubscription.objects.create_orders()
self.assertEquals(len(i['orders_created']), 0)
# default sub orders after first sub end
with patch_today(2013, 1, 6, 1, 1, 1) as pt:
# create
i = UserSubscription.objects.create_orders()
self.assertEquals(len(i['orders_created']), 2)
self.assertEquals(len(i['subs_suspended']), 0)
# attempt dup
i = UserSubscription.objects.create_orders()
self.assertEquals(len(i['orders_created']), 0)
self.assertEquals(len(i['subs_suspended']), 0)
# default sub orders during second period
with patch_today(2013, 1, 8, 1, 1, 1) as pt:
i = UserSubscription.objects.create_orders()
self.assertEquals(len(i['orders_created']), 0)
self.assertEquals(len(i['subs_suspended']), 0)
# default sub orders after second period
with patch_today(2013, 1, 17, 1, 1, 1) as pt:
# create
i = UserSubscription.objects.create_orders()
self.assertEquals(len(i['orders_created']), 1)
self.assertEquals(len(i['subs_suspended']), 1)
# attempt dup
i = UserSubscription.objects.create_orders()
self.assertEquals(len(i['orders_created']), 0)
self.assertEquals(len(i['subs_suspended']), 0)
# default sub orders after third period
with patch_today(2013, 2, 10, 1, 1, 1) as pt:
# create
i = UserSubscription.objects.create_orders()
self.assertEquals(len(i['orders_created']), 1)
self.assertEquals(len(i['subs_suspended']), 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment