def test_preprint_provider_form(self): formatted_rule = [[[self.parent_1._id], True]] new_data = { '_id': 'newname', 'name': 'New Name', 'share_publish_type': 'Preprint', 'subjects_chosen': '{}, {}, {}, {}'.format(self.parent_1.id, self.child_1.id, self.child_2.id, self.grandchild_1.id), 'toplevel_subjects': [self.parent_1.id], 'subjects_acceptable': '[]', 'preprint_word': 'preprint' } form = PreprintProviderForm(data=new_data) nt.assert_true(form.is_valid()) new_provider = form.save() nt.assert_equal(new_provider.name, new_data['name']) nt.assert_equal(new_provider.subjects_acceptable, formatted_rule)
def test_html_fields_are_stripped(self): new_data = { '_id': 'newname', 'name': 'New Name', 'share_publish_type': 'Preprint', 'subjects_chosen': '{}, {}, {}, {}'.format( self.parent_1.id, self.child_1.id, self.child_2.id, self.grandchild_1.id ), 'type': 'osf.preprintprovider', 'toplevel_subjects': [self.parent_1.id], 'subjects_acceptable': '[]', 'advisory_board': '<div><ul><li>Bill<i class="fa fa-twitter"></i> Nye</li></ul></div>', 'description': '<span>Open Preprints <code>Open</code> Science<script></script></span>', 'footer_links': '<p>Xiv: <script>Support</script> | <pre>Contact<pre> | <a href=""><span class="fa fa-facebook"></span></a></p>', 'preprint_word': 'preprint' } stripped_advisory_board = '<div><ul><li>Bill Nye</li></ul></div>' stripped_description = '<span>Open Preprints Open Science</span>' stripped_footer_links = '<p>Xiv: Support | </p>Contact | <a href=""><span class="fa fa-facebook"></span></a><p></p>' form = PreprintProviderForm(data=new_data) nt.assert_true(form.is_valid()) new_provider = form.save() nt.assert_equal(new_provider.name, new_data['name']) nt.assert_equal(new_provider.description, stripped_description) nt.assert_equal(new_provider.footer_links, stripped_footer_links) nt.assert_equal(new_provider.advisory_board, stripped_advisory_board)
def test_html_fields_are_stripped(self): new_data = { '_id': 'newname', 'name': 'New Name', 'share_publish_type': 'Preprint', 'subjects_chosen': '{}, {}, {}, {}'.format( self.parent_1.id, self.child_1.id, self.child_2.id, self.grandchild_1.id ), 'type': 'osf.preprintprovider', 'toplevel_subjects': [self.parent_1.id], 'subjects_acceptable': '[]', 'advisory_board': '<div><ul><li>Bill<i class="fa fa-twitter"></i> Nye</li></ul></div>', 'description': '<span>Open Preprints <code>Open</code> Science<script></script></span>', 'footer_links': '<p>Xiv: <script>Support</script> | <pre>Contact<pre> | <a href=""><span class="fa fa-facebook"></span></a></p>', 'preprint_word': 'preprint' } stripped_advisory_board = '<div><ul><li>Bill Nye</li></ul></div>' stripped_description = '<span>Open Preprints Open Science</span>' stripped_footer_links = '<p>Xiv: Support | </p>Contact | <a href=""><span class="fa fa-facebook"></span></a><p></p>' form = PreprintProviderForm(data=new_data) nt.assert_true(form.is_valid()) new_provider = form.save() nt.assert_equal(new_provider.name, new_data['name']) nt.assert_equal(new_provider.description, stripped_description) nt.assert_equal(new_provider.footer_links, stripped_footer_links) nt.assert_equal(new_provider.advisory_board, stripped_advisory_board)
def test_preprint_provider_form(self): formatted_rule = [[[self.parent_1._id], True]] new_data = { '_id': 'newname', 'name': 'New Name', 'share_publish_type': 'Preprint', 'subjects_chosen': '{}, {}, {}, {}'.format( self.parent_1.id, self.child_1.id, self.child_2.id, self.grandchild_1.id ), 'toplevel_subjects': [self.parent_1.id], 'subjects_acceptable': '[]', 'preprint_word': 'preprint' } form = PreprintProviderForm(data=new_data) nt.assert_true(form.is_valid()) new_provider = form.save() nt.assert_equal(new_provider.name, new_data['name']) nt.assert_equal(new_provider.subjects_acceptable, formatted_rule)