Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions framework/forms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,6 @@ def sanitize(s, **kwargs):
return sanitize_html(s, **kwargs)


def process_data(data, func):
if isinstance(data, dict):
return {
key: process_data(value, func)
for key, value in data.items()
}
elif isinstance(data, list):
return [
process_data(item, func)
for item in data
]
return func(data)


def process_payload(data):
return process_data(
data,
lambda value: quote(value.encode('utf-8') if value else '', safe=' ')
)


def unprocess_payload(data):
return process_data(
data,
lambda value: unquote(value.encode('utf-8') if value else '')
)


def jsonify(form):
"""Cast WTForm to JSON object.

Expand Down
31 changes: 0 additions & 31 deletions tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,6 @@
email_digest = 'email_digest'


class TestEventNotImplemented(OsfTestCase):
"""
Test non-implemented errors
"""
@register('not_implemented')
class NotImplementedEvent(Event):
pass

def setUp(self):
super().setUp()
self.user = factories.UserFactory()
self.auth = Auth(user=self.user)
self.node = factories.ProjectFactory(creator=self.user)
self.event = self.NotImplementedEvent(self.user, self.node, 'not_implemented')

def test_text(self):
with raises(NotImplementedError):
text = self.event.text_message

def test_html(self):
with raises(NotImplementedError):
html = self.event.html_message

def test_url(self):
with raises(NotImplementedError):
url = self.event.url

def test_event(self):
with raises(NotImplementedError):
event = self.event.event_type


class TestListOfFiles(OsfTestCase):
"""
Expand Down
13 changes: 0 additions & 13 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pytest
from django.core.exceptions import ValidationError

from framework.forms.utils import process_payload
from osf.models import RegistrationSchema
from osf.utils.migrations import ensure_schemas
from website.project.metadata.schemas import OSF_META_SCHEMA_FILES
Expand Down Expand Up @@ -31,18 +30,6 @@ def test_registrationschema_is_fine_with_same_name_but_different_version(self):
RegistrationSchema(name='foo', schema={'foo': 42}, schema_version=2).save()
assert RegistrationSchema.objects.filter(name='foo').count() == 2

def test_process(self):
processed = process_payload({'foo': 'bar&baz'})
assert processed['foo'] == 'bar%26baz'

def test_process_list(self):
processed = process_payload({'foo': ['bar', 'baz&bob']})
assert processed['foo'][1] == 'baz%26bob'

def test_process_whitespace(self):
processed = process_payload({'foo': 'bar baz'})
assert processed['foo'] == 'bar baz'


if __name__ == '__main__':
unittest.main()
47 changes: 23 additions & 24 deletions tests/test_misc_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,29 +769,29 @@ def test_view_comments_updates_user_comments_view_timestamp_files(self):

# Regression test for https://openscience.atlassian.net/browse/OSF-5193
# moved from tests/test_comments.py
def test_find_unread_includes_edited_comments(self):
project = ProjectFactory()
user = AuthUserFactory()
project.add_contributor(user, save=True)
comment = CommentFactory(node=project, user=project.creator)
n_unread = Comment.find_n_unread(user=user, node=project, page='node')
assert n_unread == 1

url = project.api_url_for('update_comments_timestamp')
payload = {'page': 'node', 'rootId': project._id}
self.app.put(url, json=payload, auth=user.auth)
user.reload()
n_unread = Comment.find_n_unread(user=user, node=project, page='node')
assert n_unread == 0

# Edit previously read comment
comment.edit(
auth=Auth(project.creator),
content='edited',
save=True
)
n_unread = Comment.find_n_unread(user=user, node=project, page='node')
assert n_unread == 1
def test_find_unread_includes_edited_comments(self):
project = ProjectFactory()
user = AuthUserFactory()
project.add_contributor(user, save=True)
comment = CommentFactory(node=project, user=project.creator)
n_unread = Comment.find_n_unread(user=user, node=project, page='node')
assert n_unread == 1

url = project.api_url_for('update_comments_timestamp')
payload = {'page': 'node', 'rootId': project._id}
self.app.put(url, json=payload, auth=user.auth)
user.reload()
n_unread = Comment.find_n_unread(user=user, node=project, page='node')
assert n_unread == 0

# Edit previously read comment
comment.edit(
auth=Auth(project.creator),
content='edited',
save=True
)
n_unread = Comment.find_n_unread(user=user, node=project, page='node')
assert n_unread == 1

@mock.patch('website.views.PROXY_EMBER_APPS', False)
class TestResolveGuid(OsfTestCase):
Expand Down Expand Up @@ -834,4 +834,3 @@ def test_preprint_provider_with_osf_domain(self, mock_use_ember_app):
url = web_url_for('resolve_guid', _guid=True, guid=preprint._id)
res = self.app.get(url)
mock_use_ember_app.assert_called_with()

138 changes: 0 additions & 138 deletions tests/test_node_licenses.py

This file was deleted.

13 changes: 0 additions & 13 deletions tests/test_preprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,6 @@ def test_verified_publishable(self, preprint):
preprint.deleted = None
assert preprint.verified_publishable is True

def test_is_deleted(self, preprint):
assert preprint.deleted is None
assert preprint.is_deleted is False

preprint.deleted = timezone.now()
preprint.save()

assert preprint.deleted is not None
assert preprint.is_deleted is True

def test_has_submitted_preprint(self, preprint):
preprint.machine_state = 'initial'
preprint.save()
Expand Down Expand Up @@ -168,9 +158,6 @@ def test_all_tags(self, preprint, auth):
assert len(preprint.all_tags) == 1
assert preprint.all_tags[0].name == 'test_tag_1'

def test_system_tags(self, preprint):
assert preprint.system_tags.exists() is False


class TestPreprintSubjects:

Expand Down
Loading