Implement a pytest plugin to help with testing

Aberta
#135 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
35/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
python
Domínio
testing

Direção de pesquisa

Comece lendo a discussão sobre pytest-plugin na PR #5108 e os exemplos de fixture e context-manager solicitados nesta issue. Considera-se concluído quando uma fixture reutilizável do pytest ou um context-manager sobrescrever is_feature_enabled, get_flag e get_feature_value para os valores de Flag fornecidos dentro do escopo do teste.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

As part of some work in the core Flagsmith repository, we found that there isn't currently a good, generic solution for mocking the flagsmith client to return a given value for a flag at a given time. The ideal implementation as I see it would be to build a fixture that can be used as a context manager, or a function that looks something like this:

def my_test_function(set_flags: FlagsmithSetFlagsFixture) -> None:
    with override_flagsmith(flags=[Flag(name="foo", enabled=True, value="foobar")]):
        # in here, any calls to Flags.is_feature_enabled,Flags.get_flag and Flags.get_feature_value 
        # for the feature "foo" will return the values provided as an argument to override_flagsmith
        ...

def my_other_test_function(set_flags: FlagsmithSetFlagsFixture) -> None:
    set_flags(flags=[Flag(name="foo", enabled=True, value="foobar")])
    
    # For the remainder of this test, any calls to Flags.is_feature_enabled,Flags.get_flag 
    # and Flags.get_feature_value for the feature "foo" will return the values provided as 
    # an argument to override_flagsmith

See PR here for more context / discussions

Linguagem predominante
Python
Estrelas
24
Forks
12
Merge médio
15h 43min
PRs com merge (30d)
4

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de Flagsmith/flagsmith-python-client

Todas as issues de Flagsmith/flagsmith-python-client

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.