-
Notifications
You must be signed in to change notification settings - Fork 111
Add tests for registration #66
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я сперва тоже попытался сделать по образу и подобию кода из лекции, но чёт быстро там всё причесать и куда надо положить у меня не вышло). Не уверен, что эти тесты рабочие, но выглядит всё здорово
'date_of_birth': mf('datetime.date'), | ||
'job_title': mf('person.occupation'), | ||
'phone': mf('person.telephone'), | ||
'phone_type': mf('choice', items=[1, 2, 3]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А это поле было в лекции, но в проекте такого поля у User'а нет. Вроде в assert_correct_user должны споткнуться об это, но если тесты проходят - стоит обратить внимание на это
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend using linters consistently. Check for plugins in your IDE that can highlight code issues and offer automatic fixes.
Understand how to globally silence certain linter errors. This way, you won't overuse type: ignore, especially if you choose not to add docstrings to every function.
Lastly, consider writing a shell script to automatically check with linters like flake8, pylint, and mypy or manually run them from IDE integrated shell.
PS. Sorry for the accidental approval.
|
||
|
||
@final | ||
class RegistrationData(UserData, total=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Remove total=false
By default, all attributes are required. Isn't this the case with password1
and password2
?
class RegistrationData(UserData, total=False): | |
class RegistrationData(UserData): |
'phone_type': mf('choice', items=[1, 2, 3]), | ||
}, iterations=1) | ||
return { | ||
**next(schema), # type: ignore[typeddict-item] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Using next(schema)
is much cleaner than mine schema.create()[0]
Does it work fine? =)
@@ -22,5 +22,5 @@ class FavouritePicture(TimedMixin, models.Model): | |||
url = models.URLField() | |||
|
|||
def __str__(self) -> str: | |||
"""Beatuful representation.""" | |||
"""Beautiful representation.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: If you're using VSCode, there's a plugin called 'Code Spell Checker'.
It's useful for catching typos, though it can produce false errors with variable names.
"""User registration data factory.""" | ||
|
||
|
||
@pytest.fixture(scope="session") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
polish: Please use either single or double quotes consistently.
Linters typically flag such inconsistencies. I noticed you used single quotes below. Plugins can assist with this, and you can even set up auto-formatting on save to automate this.
There are many minor improvements in the code quality that can be made automatically using linters at no extra cost.
@pytest.fixture(scope="session") | |
@pytest.fixture(scope='session') |
No description provided.