Skip to content

Commit

Permalink
Moved util unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
kbecker42 committed Sep 20, 2024
1 parent 6bdf1fc commit 5cdd6c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
11 changes: 11 additions & 0 deletions test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,17 @@ def test_delete_redis_keys(self):
assert result == True
assert len(list(test_sentinel.slave.keys(pattern))) == 0

def test_get_last_name(self):
assert util.get_last_name('Sara Smith') == 'Smith'
assert util.get_last_name('Sara Two Smith') == 'Smith'
assert util.get_last_name('Sara Smith 2') == 'Smith'
assert util.get_last_name('3 Sara Smith') == 'Smith'
assert util.get_last_name('Smith 1') == 'Smith'
assert util.get_last_name('Smith') == 'Smith'
assert util.get_last_name('Sara Smith ') == 'Smith'
assert util.get_last_name(' Sara Smith ') == 'Smith'
assert util.get_last_name('') == ''
assert util.get_last_name(None) == ''

class TestIsReservedName(object):
from test import flask_app as app
Expand Down
15 changes: 1 addition & 14 deletions test/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from unittest.mock import patch, Mock, call, MagicMock
from flask import redirect
from itsdangerous import BadSignature
from pybossa.util import get_user_signup_method, unicode_csv_reader, get_last_name
from pybossa.util import get_user_signup_method, unicode_csv_reader
from bs4 import BeautifulSoup
from requests.exceptions import ConnectionError
from pybossa.model.project import Project
Expand All @@ -59,7 +59,6 @@
from datetime import datetime, timedelta
import six
from pybossa.view.account import get_user_data_as_form
from pybossa.view.projects import get_last_name
from pybossa.cloud_store_api.s3 import upload_json_data
from pybossa.task_creator_helper import get_gold_answers

Expand Down Expand Up @@ -9967,18 +9966,6 @@ def test_get_assign_users_to_project(self):
assert user2.fullname in str(res.data), user2.fullname + ' not found on assign-users page.'
assert user3.fullname not in str(res.data), user3.fullname + ' is disabled and should not be found on assign-users page.'

def test_get_last_name(self):
assert get_last_name('Sara Smith') == 'Smith'
assert get_last_name('Sara Two Smith') == 'Smith'
assert get_last_name('Sara Smith 2') == 'Smith'
assert get_last_name('3 Sara Smith') == 'Smith'
assert get_last_name('Smith 1') == 'Smith'
assert get_last_name('Smith') == 'Smith'
assert get_last_name('Sara Smith ') == 'Smith'
assert get_last_name(' Sara Smith ') == 'Smith'
assert get_last_name('') == ''
assert get_last_name(None) == ''

@with_context
@patch('pybossa.view.account.send_mail', autospec=True)
@patch('pybossa.view.account.mail_queue', autospec=True)
Expand Down

0 comments on commit 5cdd6c4

Please sign in to comment.