Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# features/contact.feature
Feature: Contact form
Make sure that the contact form on XPC works as expected
Scenario: Company sending an email
Given a company member going to the contact form
When he fills the form
| name | value |
| lastName | Snow |
| firstName | John |
| email | |
| phoneNumber | 00000000000 |
| companyName | The North |
| industry | IT |
| comment | How does this work ? |
| agreeTerms | true |
Then he sees a thank you message
And emails are sent
| to | subject |
| | GOuniteWebサイトからのお問合せ |
| | GOuniteWebサイトへのお問い合わせ内容確認 |
# features/steps/
from behave import given, then, when
from django.core import mail
@given(u"a company member going to the contact form")
def step_impl(context):
@when(u"he fills the form") # noqa F811
def step_impl(context):
field_values = {k: v for k, v in context.table}
context.browser.fill_form(field_values, name="contact_form")
form = context.browser.find_by_tag("form").first
@then(u"he sees a thank you message") # noqa F811
def step_impl(context):
context.test.assertEqual(context.browser.url, "https://xpc.gounite.test/complete")
@then(u"emails are sent") # noqa F811
def step_impl(context):
context.test.assertEqual(len(mail.outbox), 2)
for i, row in enumerate(context.table):
context.test.assertEqual(mail.outbox[i].to, [row["to"]])
context.test.assertEqual(mail.outbox[i].subject, row["subject"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.