def test_if_has_duplicates_redirect_lexeme_id_blank(monkeypatch): monkeypatch.setattr(lexeme_forms, 'find_duplicates', lambda template, form_data: ['duplicate']) monkeypatch.setattr(lexeme_forms, 'add_form_data_to_template', lambda form_data, template: True) monkeypatch.setattr(flask, 'render_template', lambda template_file_name, **kwargs: True) assert lexeme_forms.if_has_duplicates_redirect( minimal_template, False, {'lexeme_id': ''}) is not None
def test_if_has_duplicates_redirect_some_duplicates(monkeypatch): monkeypatch.setattr(lexeme_forms, 'find_duplicates', lambda template, form_data: ['duplicate']) monkeypatch.setattr(lexeme_forms, 'add_form_data_to_template', lambda form_data, template: True) monkeypatch.setattr( flask, 'render_template', lambda template_file_name, **kwargs: 'rendered duplicates') assert lexeme_forms.if_has_duplicates_redirect(minimal_template, False, {}) == 'rendered duplicates'
def test_if_has_duplicates_redirect_no_duplicates(monkeypatch): monkeypatch.setattr(lexeme_forms, 'find_duplicates', lambda template, form_data: []) assert lexeme_forms.if_has_duplicates_redirect({}, False, {}) is None
def test_if_has_duplicates_redirect_lexeme_id_specified(): assert lexeme_forms.if_has_duplicates_redirect( {}, False, {'lexeme_id': 'L123'}) is None
def test_if_has_duplicates_redirect_checkbox_checked(): assert lexeme_forms.if_has_duplicates_redirect( {}, False, {'no_duplicate': True}) is None