-
-
Notifications
You must be signed in to change notification settings - Fork 775
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
Testing workshop #9668
Merged
Merged
Testing workshop #9668
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5ea3e01
updated to ignore tool versions for local python version management
b491318
remove whitespace
e040797
update factory locations for testing workshop
38134bd
update module path for cy_create_grants
22432b7
update factories and tests
12805ff
prep for testing workshop
ab1c515
tests from workshop
c87d81e
updated location of factory in import
39e6b91
update test and factory for grant_clr
cd71b24
Update .gitignore
ksolo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,3 +61,6 @@ _build/ | |
# cypress artifacts | ||
cypress/videos | ||
cypress/screenshots | ||
|
||
# asdf-vm (https://asdf-vm.com/) | ||
.tool-versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .bounty_factory import BountyFactory | ||
from .fulfillment_factory import FulfillmentFactory | ||
from .profile_factory import ProfileFactory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from attr import has | ||
import pytest | ||
|
||
from dashboard.models import BountyFulfillment | ||
from dashboard.tests.factories.fulfillment_factory import FulfillmentFactory | ||
from dashboard.tests.factories.bounty_factory import BountyFactory | ||
|
||
@pytest.mark.django_db | ||
class TestBountyFulfillmentProperties: | ||
def test_fulfillment_has_bounty(self): | ||
fulfillment = FulfillmentFactory() | ||
assert hasattr(fulfillment, 'bounty') | ||
|
||
def test_deleting_bounty_deletes_fulfillment(self): | ||
bounty = BountyFactory() | ||
fulfillment = FulfillmentFactory(bounty=bounty) | ||
|
||
bounty.delete() | ||
|
||
with pytest.raises(BountyFulfillment.DoesNotExist): | ||
fulfillment.refresh_from_db() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from .cart_activity_factory import CartActivityFactory | ||
from .clr_match_factory import CLRMatchFactory | ||
from .contribution_factory import ContributionFactory | ||
from .donation_factory import DonationFactory | ||
from .flag_factory import FlagFactory | ||
from .grant_api_key_factory import GrantAPIKeyFactory | ||
from .grant_branding_routing_policy_factory import GrantBrandingRoutingPolicyFactory | ||
from .grant_category_factory import GrantCategoryFactory | ||
from .grant_clr_calculation_factory import GrantCLRCalculationFactory | ||
from .grant_clr_factory import GrantCLRFactory | ||
from .grant_collection_factory import GrantCollectionFactory | ||
from .grant_factory import GrantFactory | ||
from .grant_stat_factory import GrantStatFactory | ||
from .grant_type_factory import GrantTypeFactory | ||
from .match_pledge_factory import MatchPledgeFactory | ||
from .subscription_factory import SubscriptionFactory |
8 changes: 4 additions & 4 deletions
8
...models/factories/cart_activity_factory.py → .../tests/factories/cart_activity_factory.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import random | ||
|
||
import factory | ||
import pytest | ||
from dashboard.tests.factories.profile_factory import ProfileFactory | ||
from dashboard.tests.factories import ProfileFactory | ||
from grants.models.cart_activity import CartActivity | ||
|
||
from .grant_factory import GrantFactory | ||
|
||
|
||
@pytest.mark.django_db | ||
class CartActivityFactory(factory.django.DjangoModelFactory): | ||
"""Create mock CartActivity for testing.""" | ||
|
||
class Meta: | ||
model = CartActivity | ||
|
||
grant = factory.SubFactory(GrantFactory) | ||
profile = factory.SubFactory(ProfileFactory) | ||
action = '' | ||
action = factory.LazyFunction(lambda: random.choice(CartActivity.ACTIONS)[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...models/factories/grant_api_key_factory.py → .../tests/factories/grant_api_key_factory.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
.../grant_branding_routing_policy_factory.py → .../grant_branding_routing_policy_factory.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
from random import randint | ||
|
||
import factory | ||
from grants.models.grant_branding_routing_policy import GrantBrandingRoutingPolicy | ||
|
||
|
||
class GrantBrandingRoutingPolicyFactory(factory.django.DjangoModelFactory): | ||
"""Create mock GrantBrandingRoutingPolicy for testing.""" | ||
|
||
class Meta: | ||
model = GrantBrandingRoutingPolicy | ||
|
||
priority = 1 | ||
priority = factory.LazyFunction(lambda: randint(1, 255)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
from datetime import datetime, timedelta | ||
from random import choice | ||
|
||
import factory | ||
import pytest | ||
from grants.models.grant import GrantCLR | ||
|
||
from dashboard.tests.factories import ProfileFactory | ||
|
||
|
||
@pytest.mark.django_db | ||
class GrantCLRFactory(factory.django.DjangoModelFactory): | ||
"""Create mock GrantCLR for testing.""" | ||
|
||
class Meta: | ||
model = GrantCLR | ||
|
||
round_num = 2 | ||
start_date = datetime.now() | ||
end_date = start_date + timedelta(weeks=2) | ||
is_active = True | ||
type='main' | ||
banner_text='text which appears below banner' | ||
round_num = factory.Faker('pyint') | ||
start_date = factory.LazyFunction(datetime.now) | ||
end_date = factory.LazyAttribute(lambda o: o.start_date + timedelta(weeks=2)) | ||
type = factory.LazyFunction(lambda: choice(GrantCLR.CLR_TYPES)[0]) | ||
banner_text = factory.Faker('catch_phrase') | ||
owner = factory.SubFactory(ProfileFactory) |
4 changes: 1 addition & 3 deletions
4
...els/factories/grant_collection_factory.py → ...sts/factories/grant_collection_factory.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
How come were removing all of these descriptions?
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 removed them because they were technically not correct, these are factories not mocks. I also didn't think they added context. I am happy to put them back in though with the correction that they are factories that return instances of the Django Model.
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.
Thats cool with me, I think they're well enough named that we don't need the descriptions!