def test_build(self): context = {'lang': 'es'} options = default_options_plus(context={'local time': '8:53pm'}) # expect the original context to have been merged with the context specified in the options expected_data = clone(options) expected_data.update(context={'lang': 'es', 'local time': '8:53pm'}) expected = default_command_with_data(**expected_data) self.assertEqual(CommandsTrack(context).build(options), expected)
def test_build(self): context = {'test': '1'} options = default_options_plus(context={'color': 'blue'}) # expect the original context to have been merged with the context specified in the options expected_data = clone(options) expected_data.update(context={'test': '1', 'color': 'blue'}) expected = default_command_with_data(**expected_data) self.assertEqual(CommandsIdentify(context).build(options), expected)
def test_reset_build(self): context = {'lang': 'es'} options = default_options_plus(reset=True, context={ 'lang': 'es', 'local time': '8:53pm', 'ip': '127.0.0.1', 'user_agent': 'Chrome' }) # expect the original context to have been merged with the context specified in the options expected_data = clone(options) expected_data.update( context={ 'lang': 'es', 'local time': '8:53pm', 'ip': '127.0.0.1', 'user_agent': 'Chrome' }) expected = default_reset_command_with_data(**expected_data) self.assertEqual(CommandsImpersonate(context).build(options), expected)
def __init__(self, source): self.source_copy = clone(source)
def test_clone(self): params = {'foo': 'bar'} new_params = clone(params) self.assertEqual(params, new_params) self.assertIsNot(new_params, params)
def call(initial_context, request_context): source_copy = clone(initial_context) deep_merge(source_copy, request_context) return source_copy