<commit_before>from django.test import RequestFactory
from nose.tools import *  # flake8: noqa

from tests.base import AdminTestCase
from tests.factories import NodeFactory
from admin_tests.utilities import setup_view

from admin.nodes.views import NodeFormView
from admin.nodes.forms import NodeForm


class NodeFormViewTest(AdminTestCase):
    def setUp(self):
        super(NodeFormViewTest, self).setUp()

    def test_context_data_not_existing_guid(self):
        guid = '12345'
        request = RequestFactory().get('/fake-path/?guid={}'.format(guid))
        view = NodeFormView()
        view = setup_view(view, request)
        with assert_raises(AttributeError):
            view.get_context_data()

    def test_context_data_no_guid(self):
        request = RequestFactory().get('/fake-path')
        view = NodeFormView()
        view = setup_view(view, request)
        res = view.get_context_data()
        assert_is_instance(res['form'], NodeForm)
        assert_is_instance(res['view'], NodeFormView)
        assert_is_none(res['guid_object'])

    def test_context_data_load(self):
        node = NodeFactory()
        guid = node._id
        request = RequestFactory().get('/fake-path/?guid={}'.format(guid))
        view = NodeFormView()
        view = setup_view(view, request)
        res = view.get_context_data()
        assert_is_instance(res['form'], NodeForm)
        assert_is_instance(res['view'], NodeFormView)
        assert_is_instance(res['guid_object'], dict)<commit_msg>Add a few more tests<commit_after>from django.test import RequestFactory
from nose.tools import *  # flake8: noqa

from tests.base import AdminTestCase
from tests.factories import NodeFactory
from admin_tests.utilities import setup_view

from admin.nodes.views import NodeFormView
from admin.nodes.forms import NodeForm


class NodeFormViewTest(AdminTestCase):
    def setUp(self):
        super(NodeFormViewTest, self).setUp()

    def test_context_data_not_existing_guid(self):
        guid = '12345'
        request = RequestFactory().get('/fake-path/?guid={}'.format(guid))
        view = NodeFormView()
        view = setup_view(view, request)
        with assert_raises(AttributeError):
            view.get_context_data()

    def test_context_data_no_guid(self):
        request = RequestFactory().get('/fake-path')
        view = NodeFormView()
        view = setup_view(view, request)
        res = view.get_context_data()
        assert_is_instance(res['form'], NodeForm)
        assert_is_instance(res['view'], NodeFormView)
        assert_is_none(res['guid_object'])

    def test_context_data_load(self):
        node = NodeFactory()
        guid = node._id
        request = RequestFactory().get('/fake-path/?guid={}'.format(guid))
        view = NodeFormView()
        view = setup_view(view, request)
        res = view.get_context_data()
        assert_is_instance(res['form'], NodeForm)
        assert_is_instance(res['view'], NodeFormView)
        assert_is_instance(res['guid_object'], dict)

    def test_success_url_implemented(self):
        node = NodeFactory()
        guid = node._id
        request = RequestFactory().get('/fake-path/?guid={}'.format(guid))
        view = NodeFormView()
        view = setup_view(view, request)
        view.get_context_data()
        assert_equal(view.success_url, u'/admin/nodes/?guid={}'.format(guid))

    def test_get_guid_object_implemented(self):
        pass
{'fraction_non_alphanumeric': 0.11272939120302942, 'fraction_numerical': 0.003495484998543548, 'mean_word_length': 3.319496855345912, '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': '1983359', 'n_tokens_mistral': 1020, 'n_tokens_neox': 993, 'n_words': 194}