Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Variable (from Examples section) interpolation inside docstrings. #124

Open
metacoma opened this issue Oct 8, 2024 · 0 comments

Comments

@metacoma
Copy link

metacoma commented Oct 8, 2024

hello, thank you for developing pytest-bdd-ng'

I am using the following approach to prepare and send a cloud event:

   Scenario: Send ping directly to function <endpoint>                                                                                                                    
      When God creates a new cloudevent                                                                                                                                    
       And God starts reading message from NATS topic ">"                                                                                                                                                                                                          
        And sets cloudevent header "ce-source" to "org.mindwm.<username>.<host>.clipboard"                                                                                 
        And sets cloudevent header "traceparent" to "<traceparent>"                                                                                                        
        And sends cloudevent to "<endpoint>"                                                                                                                               
        """                                                                                                                                                                
        {                                                                                                                                                                  
          "uuid": "4bca8a133-aba6-4f7f-ab95-242802fcac2c",                                                                                                                 
          "time": 1728325474,                                                                                                                                              
          "data": "clipboard secondary data"                                                                                                                               
        }                                                                                                                                                                  
        """                                                                                                                                                                
      Then the response http code should be "202"                                                                                                                          
                                                                                                                                                                           
      Examples:                                                                                                                                                            
       | context | username   | host      | endpoint | traceparent                   |                                                                                     
       | philadelphia   | flukeman   | the-host  | broker-ingress.knative-eventing/context-philadelphia/context-broker   | 00-5df92f3577b34da6a3ce929d0e0e4734-00f067aa0ba9  02b7-00 |                                                                                                                                                                
       | philadelphia   | flukeman   | the-host  | broker-ingress.knative-eventing/user-flukeman/user-broker | 00-6df93f3577b34da6a3ce929d0e0e4742-00f067aa0ba902b7-00 |   

If there was way to use "variables" from the Examples section inside the docstring, my scenario description would look like this.

   Scenario: Send cloudevent directly to knative function <endpoint>                                                                                                                    
      When God creates a new cloudevent                                                                                                                                    
         And God starts reading message from NATS topic ">"                                                                                                                 
         And sends cloudevent to "<endpoint>"                                                                                                                               
        """                                                                                                                                                                
        { 
           "ce-source": "org.mindwm.<username>.<host>.clipboard",
          "traceparent": "<traceparent>",                                                                                                                                                                  
          "uuid": "4bca8a133-aba6-4f7f-ab95-242802fcac2c",                                                                                                                 
          "time": 1728325474,                                                                                                                                              
          "data": "clipboard secondary data"                                                                                                                               
        }                                                                                                                                                                  
        """                                                                                                                                                                
      Then the response http code should be "202"             
      Examples:                                                                                                             
      | context | username   | host      | endpoint | traceparent                   |                                                                                     
      | philadelphia   | flukeman   | the-host  | broker-ingress.knative-eventing/context-philadelphia/context-broker   | 00-5df92f3577b34da6a3ce929d0e0e4734-00f067aa0ba9  02b7-00 |                                                                                                                                                                
      | philadelphia   | flukeman   | the-host  | broker-ingress.knative-eventing/user-flukeman/user-broker | 00-6df93f3577b34da6a3ce929d0e0e4742-00f067aa0ba902b7-00 |

I am not sure how complex this would be to implement, but I think it would be very convenient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant