def setUp(self): self.widgied = HasAWidgy() self.widgied.widgy = Layout.add_root(widgy_site).node self.widgied.save() self.widgied.widgy.get_children()[1].content.add_child(widgy_site, RawTextWidget, text='asdf') self.widgy_field = HasAWidgy._meta.get_field_by_name('widgy')[0]
def test_it_acts_like_a_foreignkey(self): x = HasAWidgy() x.widgy = Layout.add_root(widgy_site).node x.save() x = HasAWidgy.objects.get(pk=x.pk) self.assertIsInstance(x.widgy.content, Layout)
def test_no_commits(self): """ Rendering a VersionedWidgyField without any commits """ page = VersionedPage.objects.create( version_tracker=VersionTracker.objects.create( working_copy=Layout.add_root(widgy_site).node, )) field = VersionedPage._meta.get_field_by_name('version_tracker')[0] # doesn't matter what happens as long as it doesn't throw an exception field.render(page)
def test_second_save(self): instance = HasAWidgy.objects.create( widgy=Layout.add_root(widgy_site).node ) x = self.form(instance=instance, data={ 'widgy': '1', 'text_field': 'asdf', }) # what assertions can we do here? x.save()
def test_second_save(self): instance = HasAWidgy.objects.create( widgy=Layout.add_root(widgy_site).node) x = self.form(instance=instance, data={ 'widgy': '1', 'text_field': 'asdf', }) # what assertions can we do here? x.save()
def test_no_commits(self): """ Rendering a VersionedWidgyField without any commits """ page = VersionedPage.objects.create( version_tracker=VersionTracker.objects.create( working_copy=Layout.add_root(widgy_site).node, ) ) field = VersionedPage._meta.get_field_by_name('version_tracker')[0] # doesn't matter what happens as long as it doesn't throw an exception field.render(page)
def test_second_render(self): from argonauts.templatetags.argonauts import json as json_tag instance = HasAWidgy.objects.create( widgy=Layout.add_root(widgy_site).node) x = self.form(instance=instance) rendered = x.as_p() self.assertIn( 'input type="hidden" name="widgy" value="%s"' % instance.widgy.pk, rendered) self.assertIn('new Widgy', rendered) self.assertIn(json_tag(instance.widgy.to_json(widgy_site)), rendered)
def test_second_render(self): from argonauts.templatetags.argonauts import json as json_tag instance = HasAWidgy.objects.create( widgy=Layout.add_root(widgy_site).node ) x = self.form(instance=instance) rendered = x.as_p() self.assertIn('input type="hidden" name="widgy" value="%s"' % instance.widgy.pk, rendered) self.assertIn('new Widgy', rendered) self.assertIn(json_tag(instance.widgy.to_json(widgy_site)), rendered)
def orphan_helper(self): a = VersionedPage.objects.create() b = VersionedPage2.objects.create() c = VersionedPage4.objects.create() vt = VersionTracker.objects.create(working_copy=Layout.add_root(self.widgy_site).node) a.version_tracker = vt b.bar = vt a.save() b.save() VersionPageThrough.objects.create( widgy=vt, page=c, ) return vt, a, b, c
def orphan_helper(self): a = VersionedPage.objects.create() b = VersionedPage2.objects.create() c = VersionedPage4.objects.create() vt = VersionTracker.objects.create( working_copy=Layout.add_root(self.widgy_site).node) a.version_tracker = vt b.bar = vt a.save() b.save() VersionPageThrough.objects.create( widgy=vt, page=c, ) return vt, a, b, c
def test_second_save(self): # todo...I don't even know what the api for a non-modelform widgy field is root_node = Layout.add_root(widgy_site) x = self.form(initial={'widgy_field': root_node})
def setUp(self): super(RootNodeTestCase, self).setUp() self.root_node = Layout.add_root(widgy_site).node