# Path: djedi/plugins/form.py
# class BaseEditorForm(forms.Form):
#     def __init__(self, *args, **kwargs):
#         super(BaseEditorForm, self).__init__(*args, **kwargs)
# 
#         for field in list(self.fields.keys()):
#             self.fields[field].widget.__class__ = get_custom_render_widget(
#                 self.fields[field].widget.__class__
#             )
# 
# Path: djedi/tests/base.py
# class ClientTest(DjediTest, UserMixin, AssertionMixin):
# 
#     def setUp(self):
#         super(ClientTest, self).setUp()
#         master = self.create_djedi_master()
#         client = Client(enforce_csrf_checks=True)
#         client.login(username=master.username, password='test')
#         self.client = client
# 
# class DjediTest(TransactionTestCase):
# 
#     def setUp(self):
#         from cio.environment import env
#         from cio.backends import cache
#         from cio.pipeline import pipeline
#         from cio.plugins import plugins
# 
#         env.reset()
#         cache.clear()
#         pipeline.clear()
#         plugins.load()
# 
#     def tearDown(self):
#         shutil.rmtree(settings.MEDIA_ROOT, ignore_errors=True)
# 
#     @contextmanager
#     def settings(self, *args, **kwargs):
#         with super(DjediTest, self).settings(*args, **kwargs):
#             with cio_settings():
#                 configure()
#                 yield
# 
# class UserMixin(object):
# 
#     def create_djedi_master(self):
#         user = User.objects.create_superuser('master', 'master@djedi.io', 'test')
#         return user
# 
#     def create_djedi_apprentice(self):
#         user = User.objects.create_user('apprentice', email='apprentice@djedi.io', password='test')
#         group, _ = Group.objects.get_or_create(name='Djedi')
#         user.is_staff = True
#         user.groups.add(group)
#         user.save()
#         return user
# 
# Path: djedi/utils/encoding.py

# 
# Path: djedi/compat.py
# def patterns(*urls):
#         def parse_bits(parser, bits, params, varargs, varkw, defaults,
#                        takes_context, name):
#     def generic_tag_compiler(parser, token, params, varargs, varkw, defaults,
#                              name, takes_context, node_class):
#         def __init__(self, *args, **kwargs):
#     def get_cache(name):
#     def getargspec(func):
#     class TemplateResponse(BaseTemplateResponse):


import os
import simplejson as json
import cio
import cio.conf
from django.core.files import File
from django.test import Client
from django.utils.http import urlquote
from cio.backends import storage
from cio.backends.exceptions import NodeDoesNotExist, PersistenceError
from cio.plugins import plugins
from cio.utils.uri import URI
from djedi.plugins.form import BaseEditorForm
from djedi.tests.base import ClientTest, DjediTest, UserMixin
from djedi.utils.encoding import smart_unicode
from ..compat import reverse
        from djedi.plugins.img import DataForm
            file = File(image, name=image_path)
            form['data[file]'] = file
            response = self.post('api', 'i18n://sv-se@header/logo.img', form)
            self.assertEqual(response.status_code, 200)

            node = json_node(response, simple=False)
            meta = node.pop('meta')
            uri, content = node['uri'], node['content']
            self.assertEqual(uri, 'i18n://sv-se@header/logo.img#draft')
            self.assertEqual(meta['comment'], u'VW')
            html = u'<img ' \
                   u'alt="Zwitter" ' \
                   u'class="year-53" ' \
                   u'height="64" ' \
                   u'id="vw" ' \
                   u'src="/media/djedi/img/03/5e/5eba6fc2149822a8dbf76cd6978798f2ddc4ac34.png" ' \
                   u'width="64" />'
            self.assertEqual(content, html)

            # Post new resized version
            node = cio.load(uri)
            del form['data[file]']
            del form['data[crop]']
            form['data[width]'] = form['data[height]'] = u'32'
            form['data[filename]'] = node['data']['filename']

            response = self.post('api', 'i18n://sv-se@header/logo.img', form)
            self.assertEqual(response.status_code, 200)



# Path: djedi/plugins/form.py
# class BaseEditorForm(forms.Form):
#     def __init__(self, *args, **kwargs):
#         super(BaseEditorForm, self).__init__(*args, **kwargs)
# 
#         for field in list(self.fields.keys()):
#             self.fields[field].widget.__class__ = get_custom_render_widget(
#                 self.fields[field].widget.__class__
#             )
# 
# Path: djedi/tests/base.py
# class ClientTest(DjediTest, UserMixin, AssertionMixin):
# 
#     def setUp(self):
#         super(ClientTest, self).setUp()
#         master = self.create_djedi_master()
#         client = Client(enforce_csrf_checks=True)
#         client.login(username=master.username, password='test')
#         self.client = client
# 
# class DjediTest(TransactionTestCase):
# 
#     def setUp(self):
#         from cio.environment import env
#         from cio.backends import cache
#         from cio.pipeline import pipeline
#         from cio.plugins import plugins
# 
#         env.reset()
#         cache.clear()
#         pipeline.clear()
#         plugins.load()
# 
#     def tearDown(self):
#         shutil.rmtree(settings.MEDIA_ROOT, ignore_errors=True)
# 
#     @contextmanager
#     def settings(self, *args, **kwargs):
#         with super(DjediTest, self).settings(*args, **kwargs):
#             with cio_settings():
#                 configure()
#                 yield
# 
# class UserMixin(object):
# 
#     def create_djedi_master(self):
#         user = User.objects.create_superuser('master', 'master@djedi.io', 'test')
#         return user
# 
#     def create_djedi_apprentice(self):
#         user = User.objects.create_user('apprentice', email='apprentice@djedi.io', password='test')
#         group, _ = Group.objects.get_or_create(name='Djedi')
#         user.is_staff = True
#         user.groups.add(group)
#         user.save()
#         return user
# 
# Path: djedi/utils/encoding.py

# 
# Path: djedi/compat.py
# def patterns(*urls):
#         def parse_bits(parser, bits, params, varargs, varkw, defaults,
#                        takes_context, name):
#     def generic_tag_compiler(parser, token, params, varargs, varkw, defaults,
#                              name, takes_context, node_class):
#         def __init__(self, *args, **kwargs):
#     def get_cache(name):
#     def getargspec(func):
#     class TemplateResponse(BaseTemplateResponse):


# Path: djedi/tests/test_rest.py
import os
import simplejson as json
import cio
import cio.conf
from django.core.files import File
from django.test import Client
from django.utils.http import urlquote
from cio.backends import storage
from cio.backends.exceptions import NodeDoesNotExist, PersistenceError
from cio.plugins import plugins
from cio.utils.uri import URI
from djedi.plugins.form import BaseEditorForm
from djedi.tests.base import ClientTest, DjediTest, UserMixin
from djedi.utils.encoding import smart_unicode
from ..compat import reverse
        from djedi.plugins.img import DataForm

            file = File(image, name=image_path)
            form['data[file]'] = file
            response = self.post('api', 'i18n://sv-se@header/logo.img', form)
            self.assertEqual(response.status_code, 200)

            node = json_node(response, simple=False)
            meta = node.pop('meta')
            uri, content = node['uri'], node['content']
            self.assertEqual(uri, 'i18n://sv-se@header/logo.img#draft')
            self.assertEqual(meta['comment'], u'VW')
            html = u'<img ' \
                   u'alt="Zwitter" ' \
                   u'class="year-53" ' \
                   u'height="64" ' \
                   u'id="vw" ' \
                   u'src="/media/djedi/img/03/5e/5eba6fc2149822a8dbf76cd6978798f2ddc4ac34.png" ' \
                   u'width="64" />'
            self.assertEqual(content, html)

            # Post new resized version
            node = cio.load(uri)
            del form['data[file]']
            del form['data[crop]']
            form['data[width]'] = form['data[height]'] = u'32'
            form['data[filename]'] = node['data']['filename']

            response = self.post('api', 'i18n://sv-se@header/logo.img', form)
            self.assertEqual(response.status_code, 200)



class PublicRestTest(ClientTest):