Skip to content

Commit

Permalink
try fixing tests by adding enqueue decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
John Tordoff committed Mar 18, 2024
1 parent 1454e57 commit 025bcf7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions osf/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,7 @@ def deactivate_account(self):
if isinstance(req, FlaskRequest):
logout()
remove_sessions_for_user(self)
signals.user_account_deactivated.send(self)

def reactivate_account(self):
"""
Expand Down
10 changes: 10 additions & 0 deletions osf_tests/test_notable_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def ignored_notable_domain(self):
note=NotableDomain.Note.IGNORED,
)

@pytest.mark.enable_enqueue_task
@pytest.mark.parametrize('factory', [NodeFactory, CommentFactory, PreprintFactory, RegistrationFactory, UserFactory])
def test_from_spam_to_unknown_one_spam_domain(self, factory, spam_notable_domain_one, spam_notable_domain_two, unknown_notable_domain, ignored_notable_domain):
obj_one = factory()
Expand All @@ -338,6 +339,7 @@ def test_from_spam_to_unknown_one_spam_domain(self, factory, spam_notable_domain
assert obj_one.spam_status == SpamStatus.UNKNOWN
assert len(obj_one.spam_data['domains']) == 0

@pytest.mark.enable_enqueue_task
@pytest.mark.parametrize('factory', [NodeFactory, CommentFactory, PreprintFactory, RegistrationFactory, UserFactory])
def test_from_spam_to_unknown_two_spam_domains(self, factory, spam_notable_domain_one, spam_notable_domain_two, unknown_notable_domain, ignored_notable_domain):
obj_two = factory()
Expand All @@ -356,6 +358,7 @@ def test_from_spam_to_unknown_two_spam_domains(self, factory, spam_notable_domai
assert obj_two.spam_status == SpamStatus.SPAM
assert set(obj_two.spam_data['domains']) == set([self.spam_domain_two.netloc])

@pytest.mark.enable_enqueue_task
@pytest.mark.parametrize('factory', [NodeFactory, CommentFactory, PreprintFactory, RegistrationFactory, UserFactory])
def test_from_spam_to_unknown_marked_by_external(self, factory, spam_notable_domain_one, spam_notable_domain_two, unknown_notable_domain, ignored_notable_domain):
obj_three = factory()
Expand All @@ -376,6 +379,7 @@ def test_from_spam_to_unknown_marked_by_external(self, factory, spam_notable_dom
assert obj_three.spam_status == SpamStatus.SPAM
assert len(obj_three.spam_data['domains']) == 0

@pytest.mark.enable_enqueue_task
@pytest.mark.parametrize('factory', [NodeFactory, CommentFactory, PreprintFactory, RegistrationFactory, UserFactory])
def test_from_spam_to_ignored_one_spam_domain(self, factory, spam_notable_domain_one, spam_notable_domain_two, unknown_notable_domain, ignored_notable_domain):
obj_one = factory()
Expand All @@ -394,6 +398,7 @@ def test_from_spam_to_ignored_one_spam_domain(self, factory, spam_notable_domain
assert obj_one.spam_status == SpamStatus.UNKNOWN
assert len(obj_one.spam_data['domains']) == 0

@pytest.mark.enable_enqueue_task
@pytest.mark.parametrize('factory', [NodeFactory, CommentFactory, PreprintFactory, RegistrationFactory, UserFactory])
def test_from_spam_to_ignored_two_spam_domains(self, factory, spam_notable_domain_one, spam_notable_domain_two, unknown_notable_domain, ignored_notable_domain):
obj_two = factory()
Expand All @@ -412,6 +417,7 @@ def test_from_spam_to_ignored_two_spam_domains(self, factory, spam_notable_domai
assert obj_two.spam_status == SpamStatus.SPAM
assert set(obj_two.spam_data['domains']) == set([self.spam_domain_two.netloc])

@pytest.mark.enable_enqueue_task
@pytest.mark.parametrize('factory', [NodeFactory, CommentFactory, PreprintFactory, RegistrationFactory, UserFactory])
def test_from_spam_to_ignored_makred_by_external(self, factory, spam_notable_domain_one, spam_notable_domain_two, unknown_notable_domain, ignored_notable_domain):
obj_three = factory()
Expand All @@ -432,6 +438,7 @@ def test_from_spam_to_ignored_makred_by_external(self, factory, spam_notable_dom
assert obj_three.spam_status == SpamStatus.SPAM
assert len(obj_three.spam_data['domains']) == 0

@pytest.mark.enable_enqueue_task
@pytest.mark.parametrize('factory', [NodeFactory, CommentFactory, PreprintFactory, RegistrationFactory, UserFactory])
def test_from_unknown_to_spam_unknown_plus_ignored(self, factory, unknown_notable_domain, ignored_notable_domain):
obj_one = factory()
Expand All @@ -450,6 +457,7 @@ def test_from_unknown_to_spam_unknown_plus_ignored(self, factory, unknown_notabl
assert obj_one.spam_status == SpamStatus.SPAM
assert set(obj_one.spam_data['domains']) == set([self.unknown_domain.netloc])

@pytest.mark.enable_enqueue_task
@pytest.mark.parametrize('factory', [NodeFactory, CommentFactory, PreprintFactory, RegistrationFactory, UserFactory])
def test_from_unknown_to_spam_unknown_only(self, factory, unknown_notable_domain, ignored_notable_domain):
obj_two = factory()
Expand All @@ -468,6 +476,7 @@ def test_from_unknown_to_spam_unknown_only(self, factory, unknown_notable_domain
assert obj_two.spam_status == SpamStatus.SPAM
assert set(obj_two.spam_data['domains']) == set([self.unknown_domain.netloc])

@pytest.mark.enable_enqueue_task
@pytest.mark.parametrize('factory', [NodeFactory, CommentFactory, PreprintFactory, RegistrationFactory, UserFactory])
def test_from_ignored_to_spam_unknown_plus_ignored(self, factory, unknown_notable_domain, ignored_notable_domain):
obj_one = factory()
Expand All @@ -486,6 +495,7 @@ def test_from_ignored_to_spam_unknown_plus_ignored(self, factory, unknown_notabl
assert obj_one.spam_status == SpamStatus.SPAM
assert set(obj_one.spam_data['domains']) == set([self.ignored_domain.netloc])

@pytest.mark.enable_enqueue_task
@pytest.mark.parametrize('factory', [NodeFactory, CommentFactory, PreprintFactory, RegistrationFactory, UserFactory])
def test_from_ignored_to_spam_ignored_only(self, factory, unknown_notable_domain, ignored_notable_domain):
obj_two = factory()
Expand Down

0 comments on commit 025bcf7

Please sign in to comment.