def test_01_subscriptions(self): r = save_subscription(SUBSCRIPTION1) self.assertTrue(r) # Update r = save_subscription(SUBSCRIPTION2) # Get subs = get_subscription() self.assertEqual(len(subs), 1) subs = get_subscription("demo_application") self.assertEqual(len(subs), 1) otrs_sub = subs[0] self.assertEqual(otrs_sub.get("application"), "demo_application") self.assertEqual(otrs_sub.get("for_name"), "customer") self.assertEqual(otrs_sub.get("for_email"), "*****@*****.**") self.assertEqual(otrs_sub.get("num_tokens"), 200) # delete s = delete_subscription("demo_application") self.assertTrue(s) # get subs = get_subscription("demo_application") self.assertEqual(len(subs), 0)
def api_get(application=None): """ Return the subscription object as JSON. """ subscription = get_subscription() for sub in subscription: # If subscription is valid, we have a negative timedelta sub["timedelta"] = (datetime.datetime.now() - sub.get("date_till")).days return send_result(subscription)
def api_get(application=None): """ Return the subscription object as JSON. """ subscription = get_subscription() active_tokens = get_tokens(count=True, active=True, assigned=True) for sub in subscription: # If subscription is valid, we have a negative timedelta sub["timedelta"] = (datetime.datetime.now() - sub.get("date_till")).days sub["active_tokens"] = active_tokens g.audit_object.log({'success': True}) return send_result(subscription)