-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Revert changes that need to be rolled out later in phase
- Loading branch information
1 parent
6a8ac58
commit f28e35c
Showing
4 changed files
with
174 additions
and
6 deletions.
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
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 |
---|---|---|
|
@@ -32,6 +32,119 @@ def execute(self, current_user, input=None): | |
input=real_input, | ||
) | ||
|
||
#### Start of older tests | ||
|
||
@freeze_time("2022-01-01T00:00:00") | ||
def test_deprecated_update_user_when_agreement_is_false(self): | ||
self.execute( | ||
current_user=self.current_user, | ||
input={"terms_agreement": False, "customer_intent": "Business"}, | ||
) | ||
before_refresh_business_email = self.current_user.email | ||
|
||
assert self.current_user.terms_agreement == False | ||
assert self.current_user.terms_agreement_at == self.updated_at | ||
|
||
self.current_user.refresh_from_db() | ||
assert self.current_user.email == before_refresh_business_email | ||
|
||
@freeze_time("2022-01-01T00:00:00") | ||
def test_deprecated_update_user_when_agreement_is_true(self): | ||
self.execute( | ||
current_user=self.current_user, | ||
input={"terms_agreement": True, "customer_intent": "Business"}, | ||
) | ||
before_refresh_business_email = self.current_user.email | ||
|
||
assert self.current_user.terms_agreement == True | ||
assert self.current_user.terms_agreement_at == self.updated_at | ||
|
||
self.current_user.refresh_from_db() | ||
assert self.current_user.email == before_refresh_business_email | ||
|
||
@freeze_time("2022-01-01T00:00:00") | ||
def test_deprecated_update_owner_and_user_when_email_is_not_empty(self): | ||
self.execute( | ||
current_user=self.current_user, | ||
input={ | ||
"business_email": "[email protected]", | ||
"terms_agreement": True, | ||
"customer_intent": "Business", | ||
}, | ||
) | ||
|
||
assert self.current_user.terms_agreement == True | ||
assert self.current_user.terms_agreement_at == self.updated_at | ||
|
||
self.current_user.refresh_from_db() | ||
assert self.current_user.email == "[email protected]" | ||
|
||
def test_deprecated_validation_error_when_customer_intent_invalid(self): | ||
with pytest.raises(ValidationError): | ||
self.execute( | ||
current_user=self.current_user, | ||
input={"terms_agreement": None, "customer_intent": "invalid"}, | ||
) | ||
|
||
def test_deprecated_user_is_not_authenticated(self): | ||
with pytest.raises(Unauthenticated): | ||
self.execute( | ||
current_user=AnonymousUser(), | ||
input={ | ||
"business_email": "[email protected]", | ||
"terms_agreement": True, | ||
"customer_intent": "Business", | ||
}, | ||
) | ||
|
||
def test_deprecated_email_opt_in_saved_in_db(self): | ||
self.execute( | ||
current_user=self.current_user, | ||
input={ | ||
"terms_agreement": True, | ||
"marketing_consent": True, | ||
"customer_intent": "Business", | ||
}, | ||
) | ||
self.current_user.refresh_from_db() | ||
assert self.current_user.email_opt_in == True | ||
|
||
@patch( | ||
"codecov_auth.commands.owner.interactors.save_terms_agreement.SaveTermsAgreementInteractor.send_data_to_marketo" | ||
) | ||
def test_deprecated_marketo_called_only_with_consent( | ||
self, mock_send_data_to_marketo | ||
): | ||
self.execute( | ||
current_user=self.current_user, | ||
input={ | ||
"terms_agreement": True, | ||
"marketing_consent": True, | ||
"customer_intent": "Business", | ||
}, | ||
) | ||
|
||
mock_send_data_to_marketo.assert_called_once() | ||
|
||
@patch( | ||
"codecov_auth.commands.owner.interactors.save_terms_agreement.SaveTermsAgreementInteractor.send_data_to_marketo" | ||
) | ||
def test_deprecated_marketo_not_called_without_consent( | ||
self, mock_send_data_to_marketo | ||
): | ||
self.execute( | ||
current_user=self.current_user, | ||
input={ | ||
"terms_agreement": True, | ||
"marketing_consent": False, | ||
"customer_intent": "Business", | ||
}, | ||
) | ||
|
||
mock_send_data_to_marketo.assert_not_called() | ||
|
||
#### End of older tests | ||
|
||
@freeze_time("2022-01-01T00:00:00") | ||
def test_update_user_when_agreement_is_false(self): | ||
self.execute( | ||
|
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