def test_feature_update(mock_sonic_db, manifest):
    curr_feature_config = {
        'state': 'enabled',
        'auto_restart': 'enabled',
        'high_mem_alert': 'disabled',
        'set_owner': 'local',
        'has_per_asic_scope': 'False',
        'has_global_scope': 'True',
        'has_timer': 'False',
        'check_up_status': 'False',
    }
    mock_connector = Mock()
    mock_connector.get_entry = Mock(return_value=curr_feature_config)
    mock_sonic_db.get_connectors = Mock(return_value=[mock_connector])
    feature_registry = FeatureRegistry(mock_sonic_db)

    new_manifest = copy.deepcopy(manifest)
    new_manifest['service']['name'] = 'test_new'
    new_manifest['service']['delayed'] = True

    feature_registry.update(manifest, new_manifest)

    mock_connector.set_entry.assert_has_calls([
        call('FEATURE', 'test', None),
        call('FEATURE', 'test_new', {
            'state': 'enabled',
            'auto_restart': 'enabled',
            'high_mem_alert': 'disabled',
            'set_owner': 'local',
            'has_per_asic_scope': 'False',
            'has_global_scope': 'True',
            'has_timer': 'True',
            'check_up_status': 'False',
        }),
    ], any_order=True)
def test_auto_ts_feature_update_flow(mock_sonic_db, manifest):
    new_manifest = copy.deepcopy(manifest)
    new_manifest['service']['name'] = 'test_new'
    new_manifest['service']['delayed'] = True
    
    AutoTSHelp.GLOBAL_STATE = {"state" : "enabled"}
    # Mock init_cfg connector
    mock_init_cfg = Mock()
    mock_init_cfg.get_entry = Mock(side_effect=AutoTSHelp.get_entry)

    # Mock running/peristent cfg connector
    mock_other_cfg = Mock()
    mock_other_cfg.get_entry = Mock(side_effect=AutoTSHelp.get_entry_running_cfg)

    # Setup sonic_db class
    mock_sonic_db.get_connectors = Mock(return_value=[mock_init_cfg, mock_other_cfg])
    mock_sonic_db.get_initial_db_connector = Mock(return_value=mock_init_cfg)

    feature_registry = FeatureRegistry(mock_sonic_db)
    feature_registry.update(manifest, new_manifest)

    mock_init_cfg.set_entry.assert_has_calls(
        [
            call("AUTO_TECHSUPPORT_FEATURE", "test", None),
            call("AUTO_TECHSUPPORT_FEATURE", "test_new", {
                    "state" : "enabled",
                    "rate_limit_interval" : "600"
                })
        ],
        any_order = True
    )

    mock_other_cfg.set_entry.assert_has_calls(
        [
            call("AUTO_TECHSUPPORT_FEATURE", "test", None),
            call("AUTO_TECHSUPPORT_FEATURE", "test_new", {
                    "state" : "disabled",
                    "rate_limit_interval" : "1000"
                })
        ],
        any_order = True
    )