Exemple #1
0
 def test_relevant_config(self):
     assert util.relevant_config(
         [{'extensions':[666]}], '666', 'xyzzy') is None
     assert util.relevant_config(
         [{'extensions':[666],
           'start_time': '01:00',
           'end_time': '02:00'}],
         '666',
         datetime.datetime(2016, 01, 01, 00, 30)) is None
     self.assertEqual(
         util.relevant_config(
             [{'extensions':[666],
               'start_time': '01:00',
               'end_time': '02:00',
               'action': 'bar'}],
             '666',
             datetime.datetime(2016, 01, 01, 01, 30)),
         {'extensions':[666],
          'start_time': '01:00',
          'end_time': '02:00',
          'action': 'bar'})
     self.assertEqual(
         util.relevant_config(
             [{'extensions':[666],
               'start_time': '2016-01-01T01:00',
               'end_time': '2016-01-01T02:00',
               'action': 'bar'}],
             '666',
             datetime.datetime(2016, 01, 01, 01, 30)),
         {'extensions':[666],
          'start_time': '2016-01-01T01:00',
          'end_time': '2016-01-01T02:00',
          'action': 'bar'})
Exemple #2
0
def call_timeout(config, extension, now):
    """Return timeout string from config for extension and now."""
    if config:
        config_map = util.relevant_config(config, extension, now)
        if config_map:
            return timeout_to_timeout_str(config_map.get('timeout'))
    return ""
def call_timeout(config, extension, now):
    """Return timeout string from config for extension and now."""
    if config:
        config_map = util.relevant_config(config, extension, now)
        if config_map:
            return timeout_to_timeout_str(config_map.get('timeout'))
    return ""
Exemple #4
0
def test_relevant_config():
    assert util.relevant_config([], 'xyzzy', 'xyzzy') is None
    assert util.relevant_config(
        [{'extension':'666'}], '666', 'xyzzy') is None
    assert util.relevant_config(
        [{'extension':'666',
          'start_time': '01:00',
          'end_time': '02:00'}],
        '666',
        datetime.datetime(2016, 01, 01, 00, 30)) is None
    assert util.relevant_config(
        [{'extension':'666',
          'start_time': '01:00',
          'end_time': '02:00',
          'action': 'bar'}],
        '666',
        datetime.datetime(2016, 01, 01, 01, 30)) == {
            'extension':'666',
            'start_time': '01:00',
            'end_time': '02:00',
            'action': 'bar'}
def friction(agi, extension, now, context):
    config = util.read_config(config_filename)
    if config:
        config_map = util.relevant_config(config, extension, now, context)
        if config_map:
            action(action_map, config_map)(agi)
Exemple #6
0
def friction(agi, config, extension, now):
    if config:
        config_map = util.relevant_config(config, extension, now)
        if config_map:
            action(action_map, config_map)(agi)
Exemple #7
0
def friction(agi, extension, now, context):
    config = util.read_config(config_filename)
    if config:
        config_map = util.relevant_config(config, extension, now, context)
        if config_map:
            action(action_map, config_map)(agi)