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

Test(py-genres-and-actors) #529

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

baranovr
Copy link

@baranovr baranovr commented Oct 7, 2023

No description provided.

Copy link

@viktoria-rybenchuk viktoria-rybenchuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix tests

main.py Outdated
Comment on lines 7 to 14
Genre.objects.create(name="Western"),
Genre.objects.create(name="Actions"),
Genre.objects.create(name="Dramma"),
Actor.objects.create(first_name="George", last_name="Klooney"),
Actor.objects.create(first_name="Kianu", last_name="Reaves"),
Actor.objects.create(first_name="Scarlett", last_name="Keegan"),
Actor.objects.create(first_name="Will", last_name="Smith"),
Actor.objects.create(first_name="Scarlett", last_name="Johansson")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a for loop to create multiple objects to avoid redundancy

db/models.py Outdated


class Actor(models.Model):
first_name = models.CharField(max_length=255),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need , in the end?

main.py Outdated
Comment on lines 11 to 18
create_actors = [
{"first_name": "George", "last_name": "Klooney"},
{"first_name": "Kianu", "last_name": "Reaves"},
{"first_name": "Scarlett", "last_name": "Keegan"},
{"first_name": "Will", "last_name": "Smith"},
{"first_name": "Jaden", "last_name": "Smith"},
{"first_name": "Scarlett", "last_name": "Johansson"}
]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can create tuple and use unpacking in for loop

main.py Outdated
for actor_data in update_actors:
filter_fields = {
key: value for key, value in actor_data.items() if
not key.startswith("new_")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you make this check?

main.py Outdated

Actor.objects.filter(**filter_fields).update(**update_fields)

delete_genres = ["Action"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need create variable. You can make it directly

Copy link

@Dimosphen1 Dimosphen1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several changes were requested.

main.py Outdated
Comment on lines 23 to 25
update_genres = {"Dramma": "Drama"}
for old_name, new_name in update_genres.items():
Genre.objects.filter(name=old_name).update(name=new_name)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to create an update_genres variable, pass required values directly.

main.py Outdated
Comment on lines 27 to 39
Actor.objects.filter(
last_name="Klooney"
).update(
last_name="Clooney"
)

Actor.objects.filter(
first_name="Kianu", last_name="Reaves"
).update(
first_name="Keanu", last_name="Reeves"
)

Genre.objects.filter(name="Action").delete()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to perform these operations inside of the for loop.

main.py Outdated

Genre.objects.filter(name="Action").delete()

delete_actors = {"first_name": "Scarlett"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to create a delete_actors variable, pass required values directly.

main.py Outdated
Comment on lines 44 to 45
last_name_is_smith = Actor.objects.filter(
last_name="Smith").order_by("first_name")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve your line breaking so that ).order_by("first_name") would start from a new line.

@baranovr baranovr closed this Oct 8, 2023
@baranovr baranovr reopened this Oct 8, 2023
@baranovr baranovr requested a review from Dimosphen1 October 8, 2023 13:31
Copy link

@Dimosphen1 Dimosphen1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several minor changes were requested.

main.py Outdated
Comment on lines 23 to 24
for old_name, new_name in {"Dramma": "Drama"}.items():
Genre.objects.filter(name=old_name).update(name=new_name)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to make a for loop here, pass "Dramma" and "Drama" directly to the name key.

@baranovr baranovr requested a review from Dimosphen1 October 8, 2023 13:42
Copy link

@Dimosphen1 Dimosphen1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, well done!

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

Successfully merging this pull request may close these issues.

3 participants