Skip to content
This repository was archived by the owner on Dec 19, 2021. It is now read-only.

Conversation

@yunnie
Copy link
Contributor

@yunnie yunnie commented Nov 4, 2021

Description

What issue is this solving?

Closes codeforpdx/dwellingly-app/issues/640

I know the request was to add a join_staff=3 variable to the create_tenant() fixture, but I think create_tenant(3) is confusing. I would assume that it would create 3 tenants, but it creates a single tenant with 3 assigned staff.

I've set it up so that you need to use the create_join_staff fixture directly.

  staff = [create_join_staff().id for _ in range(n)]
  create_tenant(staff)

It's an additional step, but I think the intension is clearer.

@yunnie
Copy link
Contributor Author

yunnie commented Nov 4, 2021

But if everyone feels that create_tenant(n) is preferable, I can make the change.

Copy link
Member

@NickSchimek NickSchimek left a comment

Choose a reason for hiding this comment

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

create_tenant(3) is confusing. I would assume that it would create 3 tenants

Yes, I would assume that as well too. Good catch.

Everything looks good. I made a couple comments.

There are 6 commits in this PR, can you rebase/remove the irrelevant ones and force push?

Thanks!

tenant_1 = create_tenant()
tenant_2 = create_tenant()
keep_tenant = create_tenant()
tenant_1 = create_tenant([])
Copy link
Member

Choose a reason for hiding this comment

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

I'm not fond of having to know that an empty array needs to be passed in to the fixture in order for the method call to work. Can we make the parameter optional?


def test_create_tenant_with_staff(self, create_tenant, create_join_staff):
staff = [create_join_staff().id for _ in range(3)]
tenant = create_tenant(staff)
Copy link
Member

Choose a reason for hiding this comment

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

This is good.
Do you think it would be beneficial to create the staff inside of the create_tenant fixture instead?
Maybe do something like? create_tenant(staff=3). But then there is the downside of not being able to control how the staff is created. Perhaps the create_tenant fixture could be smart. If it's given a list of staff objects then it simply assigns those, if its provided an integer then it creates that many staff members and assigns them. If there are no arguments then it creates a tenant without any assigned staff.

What do you think?

@yunnie yunnie force-pushed the UpdateCrateTenantFactory branch from d77f561 to 350371e Compare November 11, 2021 04:21
Copy link
Member

@NickSchimek NickSchimek left a comment

Choose a reason for hiding this comment

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

Thanks @yunnie !

@NickSchimek NickSchimek enabled auto-merge (squash) November 15, 2021 10:08
@NickSchimek NickSchimek merged commit 0361c01 into development Nov 15, 2021
@NickSchimek NickSchimek deleted the UpdateCrateTenantFactory branch November 15, 2021 10:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create/update the create_tenant factory to optionally create assigned join staff

3 participants