<commit_before># -*- coding: utf-8 -*-
from nose.tools import *  # flake8: noqa

from api.base.settings.defaults import API_BASE
from api.citations.utils import display_absolute_url

from tests.base import ApiTestCase
from tests.factories import (
    AuthUserFactory,
    PreprintFactory,
)


class PreprintCitationsMixin(object):

	def setUp(self):
		super(PreprintCitationsMixin, self).setUp()
		self.admin_contributor = AuthUserFactory()
		self.published_preprint = PreprintFactory(creator=self.admin_contributor)
		self.unpublished_preprint = PreprintFactory(creator=self.admin_contributor, is_published=False)

	def test_unauthenticated_can_view_published_preprint_citations(self):
		res = self.app.get(self.published_preprint_url)
		assert_equal(res.status_code, 200)

	def test_unauthenticated_cannot_view_unpublished_preprint_citations(self):
		res = self.app.get(self.unpublished_preprint_url, expect_errors=True)
		assert_equal(res.status_code, 401)

	def test_preprint_citations_are_read_only(self):
		post_res = self.app.post_json_api(self.published_preprint_url, {}, auth=self.admin_contributor.auth, expect_errors=True)
		assert_equal(post_res.status_code, 405)<commit_msg>Fix import to fix tests<commit_after># -*- coding: utf-8 -*-
from api.base.settings.defaults import API_BASE
from api.citations.utils import display_absolute_url
from nose.tools import *  # flake8: noqa
from osf_tests.factories import AuthUserFactory, PreprintFactory
from tests.base import ApiTestCase


class PreprintCitationsMixin(object):

	def setUp(self):
		super(PreprintCitationsMixin, self).setUp()
		self.admin_contributor = AuthUserFactory()
		self.published_preprint = PreprintFactory(creator=self.admin_contributor)
		self.unpublished_preprint = PreprintFactory(creator=self.admin_contributor, is_published=False)

	def test_unauthenticated_can_view_published_preprint_citations(self):
		res = self.app.get(self.published_preprint_url)
		assert_equal(res.status_code, 200)

	def test_unauthenticated_cannot_view_unpublished_preprint_citations(self):
		res = self.app.get(self.unpublished_preprint_url, expect_errors=True)
		assert_equal(res.status_code, 401)

	def test_preprint_citations_are_read_only(self):
		post_res = self.app.post_json_api(self.published_preprint_url, {}, auth=self.admin_contributor.auth, expect_errors=True)
		assert_equal(post_res.status_code, 405)
{'fraction_non_alphanumeric': 0.08884210526315789, 'fraction_numerical': 0.009263157894736843, 'mean_word_length': 7.395759717314488, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7654686', 'n_tokens_mistral': 840, 'n_tokens_neox': 770, 'n_words': 121}