Skip to content

Conversation

@domi41
Copy link
Contributor

@domi41 domi41 commented Apr 27, 2020

Gherkin features ! #29

python manage.py behave

What I've got so far.

Esoteric (direct access to database)

  • Step: create user
  • Step: count users
  • Step: create poll
  • Step: count polls

Exoteric (via REST)

  • Step: register user
  • Step: submit poll
  • Step: vote in poll
  • Step: check poll winner

Tooling


This PR is definitely NOT atomic. Sorry about that. There's no way around it, the first PR is going to be big and will introduce breaking changes. I broke one thing, and once that anvil dropped…

@domi41 domi41 changed the title [WIP] Feat gherkin [WIP] Gherkin feature suite Apr 27, 2020
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.

Bug C 22 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 69 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@domi41 domi41 self-assigned this May 30, 2025
@domi41 domi41 added the testing label May 30, 2025
@domi41
Copy link
Contributor Author

domi41 commented May 30, 2025

Wait a minute…

I'd forgotten about this ! I'll clean it up.

domi41 added 24 commits May 30, 2025 19:28
BREAKING CHANGE: `LANGUAGE_AVAILABLE` -> `LANGUAGES_AVAILABLE`
Let's experiment with `behave-django`.
The directory `features/fr` ought to be a git submodule.
We now need consent from everyone about the first scenario
before we can proceed.
Keep in mind that we need to write one scenario at a time,
then implement it, and then write another.
We must not write many scenarios at once.
It's going to be tempting.  Don't do it.
https://www.lesswrong.com/posts/uHYYA32CKgKT3FagE/hold-off-on-proposing-solutions
This should be considered like a Constitution,
where each article is thoroughly debated and carefully worded.
There will be some technical constraints in Gherkin
that Constitutions don't have.
This is a meta feature about the steps in the features.
This way I can work on stuff without deciding on the scenarios.
Note how naive parse_amount() is for now. … We cheated.
"Requérir la présence à priori de scrutins."

Another brick in setting up the contexts
we'll want for our scenarios.
Language detection is a dummy for now.
But we're add a rather fault-intolerant but working YAML perser
to use with step pystrings.
I18N support is overall made of tape (not even cardboard).
Eval is Evil.
– Your friend, _The Sign Painter_
Tested:
- raw assert (not explicit)
- describe (stale)
- compare (stale)
- nose-tools (very few tools, no?)

Not tested
- behave-pytest (404, did not inquire further)
- etc.

Looks like full I18N support is not coming out of the box.
https://github.com/oboff/hamcrest/issues/80
Inquiring further…
Our language pool is the one of `text2num`.  (at least en, fr, es)
Gherkin itself is widely translated and extendable in behave IIRC.

This commit introduces a huge list of `ISO 639-1` codes.
Esperanto is often overlooked in centralized databases.
Esoteric steps run from the inside and access the database directly.
Exoteric steps run from the outside and run REST requests.
Spanish is going to be fun, I can tell.

¿que?
¿cuando se come aqui?
domi41 added 26 commits May 30, 2025 20:12
Note: Shared context variables are tempting but ought to be scarce
and carefully though of, since they often incur inertia and creep.
This may eventually support email and id.
Behave is tricky to configure in order to show the output.
This step does not yield very useful information for now,
but it allows us to debug and experiment with behave conf.
Actors provide a handy layer over requests.
Especially useful once authentication kicks in.
Right now they are empty and hacky, but the idea is there.
Just experimenting this pattern, to see if step defs get prettier.
…
And what's the cost.
Make sure when using print() in step defs to end it with a `\n`,
This is a pitfall of behave, I guess?

We can set the format to plain, using the --format plain CLI option,
since the `format = plain` in the `.behaverc` changes nothing.
When in plain format, there are no colors and our print() appears.
We tried behave 1.2.6 and 1.2.7-dev2.
This may well be solved by some tweaking.
Found out about `aloe`, and `pytest-bdd`.
This may well be solved by some experimenting.
Printing is not as good in behave as it is in other runners,
at least from an end-user perspective.
Printing is not as good in behave as it is in other runners,
at least from an end-user perspective.
We hacked (very) partial I18N support in hamcrest.
Still need to figure out if we're going to use
`gettext` or `python-i18n`, or even something else.
Perhaps behave already does this behind the scenes.
It does not affect the output of the built-in AssertionError.
We also introduce a step to pass the time.
We'll move them into a submodule or a subtree?
…

I don't understand why this bug has been alive for years.
The Formatter interface is well-thought, thankfully.
never mind, it can't be done properly for now
dropping this
@domi41
Copy link
Contributor Author

domi41 commented Jun 2, 2025

Well… Fast API is not allowing me to query the database outside of endpoints, in the step defs.

Therefore, I'm shelving this until a solution pops up.

@domi41 domi41 added invalid This doesn't seem right wontfix This will not be worked on labels Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid This doesn't seem right testing wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant