def call(self, options): ValidatorsPresent.call(options, 'event') context = ContextMerge.call(self.context, options.get('context')) context = ContextSanitize.call(context) if context: options.update({'context': context}) options.update({'sent_at': generate_timestamp.call()}) return Command(method='post', path='risk', data=options)
def call(self, options): ValidatorsPresent.call(options, 'user_id') context = ContextMerge.call(self.context, options.get('context')) context = ContextSanitize.call(context) ValidatorsPresent.call(context, 'user_agent', 'ip') if context: options.update({'context': context}) options.update({'sent_at': generate_timestamp.call()}) return Command(method='delete', path='impersonate', data=options)
def test_call_when_no_active_context(self): context = {'foo': 'bar'} self.assertEqual(ContextSanitize.call(context), {'foo': 'bar'})
def test_call_when_no_context(self): context = None self.assertEqual(ContextSanitize.call(context), {})
def test_call_when_have_active_flag(self): context = {'foo': 'bar', 'active': True} self.assertEqual(ContextSanitize.call(context), { 'foo': 'bar', 'active': True })
def test_call_when_no_active_is_string(self): context = {'foo': 'bar', 'active': 'true'} self.assertEqual(ContextSanitize.call(context), {'foo': 'bar'})