Beispiel #1
0
 def test_to_dict(self):
     from adhocracy.model import Instance
     test_instance = Instance.find('test')
     shouldbe = {
         'activation_delay': 7,
         'allow_adopt': True,
         'allow_delegate': True,
         'allow_index': True,
         'allow_propose': True,
         'allow_thumbnailbadges': False,
         'create_time': test_instance.create_time,
         'creator': u'admin',
         'default_group': u'voter',
         'hidden': False,
         'id': 1,
         'instance_url': u'http://test.test.lan/instance/test',
         'key': u'test',
         'label': u'Test Instance',
         'required_majority': 0.66,
         'thumbnailbadges_height': None,
         'thumbnailbadges_width': None,
         'url': u'http://test.test.lan/instance/test'
     }
     result = test_instance.to_dict()
     self.assertEqual(shouldbe, result)
Beispiel #2
0
    def test_get_all_badgets(self):
        #setup
        from adhocracy.model import Badge, CategoryBadge, DelegateableBadge, \
            InstanceBadge
        from adhocracy.model import UserBadge, Instance
        instance = Instance.find(u'test')
        # create for each type a global scope and an instance scope badge
        InstanceBadge.create(u'badge ü', u'#ccc', u'description ü')
        InstanceBadge.create(u'badge ü', u'#ccc', u'description ü',
                                 instance=instance)
        UserBadge.create(u'badge ü', u'#ccc', u'description ü')
        UserBadge.create(u'ü', u'#ccc', u'ü', instance=instance)
        DelegateableBadge.create(u'badge ü', u'#ccc', u'description ü')
        DelegateableBadge.create(u'badge ü', u'#ccc', u'description ü',
                                 instance=instance)
        CategoryBadge.create(u'badge ü', u'#ccc', u"desc")
        CategoryBadge.create(u'badge ü', u'#ccc', u"desc", instance=instance)

        # all instance badges
        self.assert_(len(InstanceBadge.all()) == 1)
        self.assert_(len(InstanceBadge.all(instance=instance)) == 1)
        # all delegateable badges
        self.assert_(len(DelegateableBadge.all()) == 1)
        self.assert_(len(DelegateableBadge.all(instance=instance)) == 1)
        # all delegateable category badges
        self.assert_(len(CategoryBadge.all()) == 1)
        self.assert_(len(CategoryBadge.all(instance=instance)) == 1)
        # all user badgets
        self.assert_(len(UserBadge.all()) == 1)
        self.assert_(len(UserBadge.all(instance=instance)) == 1)
        # We can get all Badges by using `Badge`
        self.assert_(len(Badge.all()) == 4)
        self.assert_(len(Badge.all(instance=instance)) == 4)

        self.assert_(len(Badge.all_q().all()) == 8)
Beispiel #3
0
 def setUp(self):
     super(TestController, self).setUp()
     # the test instance is generated by setup-app
     instance = Instance.find('test')
     assert instance, "We need an instance to setup the context"
     _register_tmpl_context(instance, user=None)
     _register_request(**self.request)
Beispiel #4
0
def valid_instance(name):
    instance = Instance.find(name)
    if instance is None:
        print(u"Invalid instance: %s" % name)
        sys.exit(1)
    else:
        return instance
Beispiel #5
0
 def setUp(self):
     super(TestController, self).setUp()
     # the test instance is generated by setup-app
     instance = Instance.find('test')
     assert instance, "We need an instance to setup the context"
     _register_tmpl_context(instance, user=None)
     _register_request(**self.request)
Beispiel #6
0
 def _to_python(self, value, state):
     from adhocracy.model import Instance
     if can.badge.manage_global() or can.badge.edit_global():
         if value:
             instance = Instance.find(value)
             if instance is None:
                 raise AssertionError("Could not find instance %s" % value)
             return instance
         return None
     elif can.badge.manage_instance() or can.badge.edit_instance():
         instance = Instance.find(value)
         if instance is not None and instance == c.instance:
             return instance
     raise formencode.Invalid(
         _("You're not allowed to edit global badges"),
         value, state)
Beispiel #7
0
def valid_instance(name):
    instance = Instance.find(name)
    if instance is None:
        print (u"Invalid instance: %s" % name)
        sys.exit(1)
    else:
        return instance
Beispiel #8
0
def _make_one(title, text, creator=None, time=None):
    from adhocracy.model import Instance, Milestone
    if creator is None:
        creator = tt_make_user()
    instance = Instance.find('test')
    now = datetime.now()
    milestone = Milestone.create(instance, creator, title, text, now)
    return (milestone, creator)
Beispiel #9
0
def _make_one(title, text, creator=None, time=None):
    from adhocracy.model import Instance, Milestone
    if creator is None:
        creator = tt_make_user()
    instance = Instance.find('test')
    now = datetime.now()
    milestone = Milestone.create(instance, creator, title, text, now)
    return (milestone, creator)
Beispiel #10
0
    def _make_content(self):
        """Returns creator, delegateable and badge"""

        from adhocracy.model import InstanceBadge, Instance
        creator = tt_make_user('creator')
        instance = Instance.create("instance2", u"instance2", creator)
        badge = InstanceBadge.create(u'testbadge', u'#ccc2', 'description')

        return creator, instance, badge
Beispiel #11
0
    def _make_content(self):
        """Returns creator, delegateable and badge"""

        from adhocracy.model import InstanceBadge, Instance
        creator = tt_make_user('creator')
        instance = Instance.create("instance2", u"instance2", creator)
        badge = InstanceBadge.create(u'testbadge', u'#ccc2', 'description')

        return creator, instance, badge
Beispiel #12
0
    def _make_content(self):
        """Returns creator, delegateable and badge"""

        from adhocracy.model import DelegateableBadge, Proposal, Instance
        instance = Instance.find('test')
        creator = tt_make_user('creator')
        delegateable = Proposal.create(instance, u"labeld", creator)
        badge = DelegateableBadge.create(u'testbadge', u'#ccc', 'description')

        return creator, delegateable, badge
Beispiel #13
0
    def _make_content(self):
        """Returns creator, delegateable and badge"""

        from adhocracy.model import Badge, Proposal, Instance
        instance = Instance.find('test')
        creator = tt_make_user('creator')
        delegateable = Proposal.create(instance, u"labeld", creator)
        badge = Badge.create(u'testbadge', u'#ccc', 'description')

        return creator, delegateable, badge
Beispiel #14
0
 def test_create_milestone(self):
     from adhocracy.model import Instance, Milestone
     now = datetime.now()
     creator = tt_make_user()
     instance = Instance.find('test')
     milestone = Milestone.create(instance, creator, u'Titleü', u'Textü',
                                  now)
     self.assertEqual(milestone.instance, instance)
     self.assertEqual(milestone.creator, creator)
     self.assertEqual(len(Milestone.all()), 1)
Beispiel #15
0
 def test_create_milestone(self):
     from adhocracy.model import Instance, Milestone
     now = datetime.now()
     creator = tt_make_user()
     instance = Instance.find('test')
     milestone = Milestone.create(instance, creator, u'Titleü', u'Textü',
                                  now)
     self.assertEqual(milestone.instance, instance)
     self.assertEqual(milestone.creator, creator)
     self.assertEqual(len(Milestone.all()), 1)
Beispiel #16
0
    def _make_content(self):
        """Returns creator, delegateable and badge"""

        from adhocracy.model import Badge, Proposal, Instance

        instance = Instance.find("test")
        creator = tt_make_user("creator")
        delegateable = Proposal.create(instance, u"labeld", creator)
        badge = Badge.create(u"testbadge", u"#ccc", "description")

        return creator, delegateable, badge
Beispiel #17
0
def post_login_url(user):
    from adhocracy.lib.helpers import base_url
    url = config.get('adhocracy.post_login_url')
    if url is None:
        return base_url('/user/%s/dashboard' % user.user_name)

    instance = config.get('adhocracy.post_login_instance')
    if instance is None:
        return base_url(url)
    else:
        return base_url(url, Instance.find(instance))
Beispiel #18
0
def post_logout_url():
    from adhocracy.lib.helpers import base_url
    url = config.get('adhocracy.post_logout_url')
    if url is None:
        return base_url()

    instance = config.get('adhocracy.post_logout_instance')
    if instance is None:
        return base_url(url)
    else:
        return base_url(url, Instance.find(instance))
Beispiel #19
0
def post_login_url(user):
    from adhocracy.lib.helpers import base_url
    url = config.get('adhocracy.post_login_url')
    if url is None:
        return base_url('/user/%s/dashboard' % user.user_name)

    instance = config.get('adhocracy.post_login_instance')
    if instance is None:
        return base_url(url)
    else:
        return base_url(url, Instance.find(instance))
Beispiel #20
0
 def _to_python(self, value, state):
     from adhocracy.model import Instance
     if not value:
         raise formencode.Invalid(_('No instance key is given'), value,
                                  state)
     if not Instance.INSTANCE_KEY.match(value) or value in FORBIDDEN_NAMES:
         raise formencode.Invalid(_('The instance key is invalid'), value,
                                  state)
     if Instance.find(value):
         raise formencode.Invalid(
             _('An instance with that key already exists'), value, state)
     return value
Beispiel #21
0
    def _make_content(self):
        """Returns creator, delegateable and badge"""

        from adhocracy.model import ThumbnailBadge, Proposal, Instance
        instance = Instance.find(u'test')
        creator = tt_make_user(u'creator')
        delegateable = Proposal.create(instance, u"labeld", creator)
        thumbnail = b'binary'
        badge = ThumbnailBadge.create(u'testbadge', u'#ccc', True,
                                      u'description', thumbnail=thumbnail)

        return creator, delegateable, badge
Beispiel #22
0
 def get_allowed_instances(cls, user):
     """
     returns all instances in which the given user has permission to send a
     message to all users
     """
     if has('global.message'):
         return Instance.all()
     else:
         return [m.instance for m in user.memberships
                 if (m.instance is not None
                     and m.instance.is_authenticated
                     and 'instance.message' in m.group.permissions)]
Beispiel #23
0
 def _to_python(self, value, state):
     from adhocracy.model import Instance
     if has('global.admin'):
         if value:
             instance = Instance.find(value)
             if instance is None:
                 raise AssertionError("Could not find instance %s" % value)
             return instance
         return None
     elif has('instance.admin') and c.instance:
         return c.instance
     raise formencode.Invalid(_("You're not allowed to edit global badges"),
                              value, state)
Beispiel #24
0
 def _get_allowed_instances(cls, user):
     """
     returns all instances in which the given user has permission to send a
     message to all users
     """
     if has('global.message'):
         return Instance.all()
     else:
         perm = Permission.find('instance.message')
         return [
             m.instance for m in user.memberships
             if (m.instance is not None and m.instance.is_authenticated
                 and perm in m.group.permissions)
         ]
Beispiel #25
0
 def _to_python(self, value, state):
     from adhocracy.model import Instance
     if has('global.admin'):
         if value:
             instance = Instance.find(value)
             if instance is None:
                 raise AssertionError("Could not find instance %s" % value)
             return instance
         return None
     elif has('instance.admin') and c.instance:
         return c.instance
     raise formencode.Invalid(
         _("You're not allowed to edit global badges"),
         value, state)
Beispiel #26
0
 def test_to_dict(self):
     from adhocracy.model import CategoryBadge, Instance
     instance = Instance.find('test')
     badge = CategoryBadge.create(u'badge', u'#ccc', u'description',
                                  instance=instance)
     result = badge.to_dict()
     result = sorted(result.items())
     expected = {'title': u'badge',
                 'color': u'#ccc',
                 'description': u'description',
                 'id': 1,
                 'instance': instance.id}
     expected = sorted(expected.items())
     self.assertEqual(result, expected)
Beispiel #27
0
 def _get_allowed_instances(cls, user):
     """
     returns all instances in which the given user has permission to send a
     message to all users
     """
     if has('global.message'):
         return Instance.all()
     else:
         perm = Permission.find('instance.message')
         instances = [m.instance for m in user.memberships
                      if (m.instance is not None
                          and m.instance.is_authenticated
                          and perm in m.group.permissions)]
         return sorted(instances, key=lambda i: i.label)
    def test_members(self):
        from adhocracy.model import Instance, Group
        test_instance = Instance.find('test')

        members = test_instance.members()
        self.assertEqual(len(members), 1)
        self.assertEqual(members[0].user_name, u'admin')
        voters = Group.find(u'Voter')
        tt_make_user(u'second', voters)

        members = test_instance.members()
        self.assertEqual(len(members), 2)
        self.assertEqual(sorted([member.user_name for member in
                                 test_instance.members()]),
                         ['admin', 'second'])
Beispiel #29
0
    def test_members(self):
        from adhocracy.model import Instance, Group
        test_instance = Instance.find('test')

        members = test_instance.members()
        self.assertEqual(len(members), 1)
        self.assertEqual(members[0].user_name, u'admin')
        voters = Group.find(u'Voter')
        tt_make_user(u'second', voters)

        members = test_instance.members()
        self.assertEqual(len(members), 2)
        self.assertEqual(
            sorted([member.user_name for member in test_instance.members()]),
            ['admin', 'second'])
Beispiel #30
0
 def _to_python(self, value, state):
     from adhocracy.model import Instance
     if not value:
         raise formencode.Invalid(
             _('No instance key is given'),
             value, state)
     if not Instance.INSTANCE_KEY.match(value) or value in FORBIDDEN_NAMES:
         raise formencode.Invalid(
             _('The instance key is invalid'),
             value, state)
     if Instance.find(value):
         raise formencode.Invalid(
             _('An instance with that key already exists'),
             value, state)
     return value
Beispiel #31
0
 def _get_allowed_instances(cls, user):
     """
     returns all instances in which the given user has permission to send a
     message to all users
     """
     if has('global.message'):
         return Instance.all(include_hidden=True)
     else:
         perm = Permission.find('instance.message')
         instances = [
             m.instance for m in user.memberships
             if (m.instance is not None and m.instance.is_authenticated
                 and perm in m.group.permissions)
         ]
         return sorted(instances, key=lambda i: i.label)
Beispiel #32
0
def get_instances(args):
    '''
    Flatten out the instances parsed by a parser from create_parser
    used with `use_instance=True`
    '''
    if args.instances:
        keys = [item for sublist in args.instances for item in sublist]
        instances = []
        for key in keys:
            obj = Instance.find(key)
            if obj is None:
                raise ValueError("Instance '%s' does not exist" % key)
            instances.append(obj)
        return instances
    return None
Beispiel #33
0
def get_instances(args):
    '''
    Flatten out the instances parsed by a parser from create_parser
    used with `use_instance=True`
    '''
    if args.instances:
        keys = [item for sublist in args.instances for item in
                sublist]
        instances = []
        for key in keys:
            obj = Instance.find(key)
            if obj is None:
                raise ValueError("Instance '%s' does not exist" % key)
            instances.append(obj)
        return instances
    return None
Beispiel #34
0
 def test_generate_thumbnail_tag_set_size(self):
     from adhocracy.model import ThumbnailBadge, Instance
     from adhocracy.lib.helpers.badge_helper import generate_thumbnail_tag
     instance = Instance.find(u'test')
     badge = ThumbnailBadge.create(u'testbadge0', u'', True, u'descr')
     badge.instance = instance
     image = generate_thumbnail_tag(badge)
     self.assert_(u'width="48"' in image)
     self.assert_(u'height="48"' in image)
     instance.thumbnailbadges_width = 10
     instance.thumbnailbadges_height = 12
     image = generate_thumbnail_tag(badge)
     self.assert_(u'height="12"' in image)
     self.assert_(u'width="10"' in image)
     image = generate_thumbnail_tag(badge, width=8, height=11)
     self.assert_(u'height="11"' in image)
     self.assert_(u'width="8"' in image)
Beispiel #35
0
 def test_generate_thumbnail_tag_set_size(self):
     from adhocracy.model import ThumbnailBadge, Instance
     from adhocracy.lib.helpers.badge_helper import generate_thumbnail_tag
     instance = Instance.find(u'test')
     badge = ThumbnailBadge.create(u'testbadge0', u'', True, u'descr')
     badge.instance = instance
     image = generate_thumbnail_tag(badge)
     self.assert_(u'width="48"' in image)
     self.assert_(u'height="48"' in image)
     instance.thumbnailbadges_width = 10
     instance.thumbnailbadges_height = 12
     image = generate_thumbnail_tag(badge)
     self.assert_(u'height="12"' in image)
     self.assert_(u'width="10"' in image)
     image = generate_thumbnail_tag(badge, width=8, height=11)
     self.assert_(u'height="11"' in image)
     self.assert_(u'width="8"' in image)
Beispiel #36
0
    def wrapper(self):
        allowed_sender_options = self._get_allowed_sender_options(c.user)
        sender_email = self.form_result.get('sender_email')
        if ((sender_email not in allowed_sender_options)
                or (not allowed_sender_options[sender_email]['enabled'])):
            return ret_abort(_("Sorry, but you're not allowed to set these "
                               "message options"),
                             code=403)
        sender_name = None
        if has('global.message'):
            sender_name = self.form_result.get('sender_name')
        if not sender_name:
            sender_name = c.user.name

        recipients = User.all_q()
        filter_instances = self.form_result.get('filter_instances')
        recipients = recipients.join(Membership).filter(
            Membership.instance_id.in_(filter_instances))
        filter_badges = self.form_result.get('filter_badges')
        if filter_badges:
            recipients = recipients.join(UserBadges,
                                         UserBadges.user_id == User.id)
            recipients = recipients.filter(
                UserBadges.badge_id.in_([fb.id for fb in filter_badges]))

        if has('global.admin'):
            include_footer = self.form_result.get('include_footer')
        else:
            include_footer = True

        if len(filter_instances) == 1:
            instance = Instance.find(filter_instances[0])
        else:
            instance = None

        return func(
            self,
            self.form_result.get('subject'),
            self.form_result.get('body'),
            recipients.all(),
            sender_email=allowed_sender_options[sender_email]['email'],
            sender_name=sender_name,
            instance=instance,
            include_footer=include_footer,
        )
Beispiel #37
0
 def test_to_dict(self):
     from adhocracy.model import CategoryBadge, Instance
     instance = Instance.find('test')
     badge = CategoryBadge.create(u'badge',
                                  u'#ccc',
                                  u'description',
                                  instance=instance)
     result = badge.to_dict()
     result = sorted(result.items())
     expected = {
         'title': u'badge',
         'color': u'#ccc',
         'description': u'description',
         'id': 1,
         'instance': instance.id
     }
     expected = sorted(expected.items())
     self.assertEqual(result, expected)
Beispiel #38
0
    def test_get_all_badges(self):
        # setup
        from adhocracy.model import Badge, CategoryBadge, DelegateableBadge, \
            InstanceBadge, ThumbnailBadge
        from adhocracy.model import UserBadge, Instance
        instance = Instance.find(u'test')
        # create for each type a global scope and an instance scope badge
        InstanceBadge.create(u'badge ü', u'#ccc', True, u'description ü')
        InstanceBadge.create(u'badge ü', u'#ccc', True, u'description ü',
                             instance=instance)
        UserBadge.create(u'badge ü', u'#ccc', True, u'description ü')
        UserBadge.create(u'ü', u'#ccc', True, u'ü', instance=instance)
        DelegateableBadge.create(u'badge ü', u'#ccc', True, u'description ü')
        DelegateableBadge.create(u'badge ü', u'#ccc', True, u'description ü',
                                 instance=instance)
        CategoryBadge.create(u'badge ü', u'#ccc', True, u"desc")
        CategoryBadge.create(u'badge ü', u'#ccc', True, u"desc",
                             instance=instance)

        ThumbnailBadge.create(u'badge ü', u'#ccc', True, u"desc",
                              thumbnail=b'binary')
        ThumbnailBadge.create(u'badge ü', u'#ccc', True, u"desc",
                              thumbnail=b'binary', instance=instance)

        # all instance badges
        self.assertEqual(len(InstanceBadge.all()), 1)
        self.assertEqual(len(InstanceBadge.all(instance=instance)), 1)
        # all delegateable badges
        self.assertEqual(len(DelegateableBadge.all()), 1)
        self.assertEqual(len(DelegateableBadge.all(instance=instance)), 1)
        # all delegateable category badges
        self.assertEqual(len(CategoryBadge.all()), 1)
        self.assertEqual(len(CategoryBadge.all(instance=instance)), 1)
        # all delegateable thumbnail badges
        self.assertEqual(len(ThumbnailBadge.all()), 1)
        self.assertEqual(len(ThumbnailBadge.all(instance=instance)), 1)
        # all user badges
        self.assertEqual(len(UserBadge.all()), 3)
        self.assertEqual(len(UserBadge.all(instance=instance)), 1)
        # We can get all Badges by using `Badge`
        self.assertEqual(len(Badge.all()), 7)
        self.assertEqual(len(Badge.all(instance=instance)), 5)

        self.assertEqual(len(Badge.all_q().all()), 12)
Beispiel #39
0
    def wrapper(self):
        allowed_sender_options = self._get_allowed_sender_options(c.user)
        sender_email = self.form_result.get('sender_email')
        if ((sender_email not in allowed_sender_options) or
                (not allowed_sender_options[sender_email]['enabled'])):
            return ret_abort(_("Sorry, but you're not allowed to set these "
                               "message options"), code=403)
        sender_name = None
        if has('global.message'):
            sender_name = self.form_result.get('sender_name')
        if not sender_name:
            sender_name = c.user.name

        recipients = User.all_q()
        filter_instances = self.form_result.get('filter_instances')
        recipients = recipients.join(Membership).filter(
            Membership.instance_id.in_(filter_instances))
        filter_badges = self.form_result.get('filter_badges')
        if filter_badges:
            recipients = recipients.join(UserBadges,
                                         UserBadges.user_id == User.id)
            recipients = recipients.filter(
                UserBadges.badge_id.in_([fb.id for fb in filter_badges]))

        if has('global.admin'):
            include_footer = self.form_result.get('include_footer')
        else:
            include_footer = True

        if len(filter_instances) == 1:
            instance = Instance.find(filter_instances[0])
        else:
            instance = None

        return func(self,
                    self.form_result.get('subject'),
                    self.form_result.get('body'),
                    recipients.all(),
                    sender_email=allowed_sender_options[sender_email]['email'],
                    sender_name=sender_name,
                    instance=instance,
                    include_footer=include_footer,
                    )
Beispiel #40
0
    def test_get_all_badgets(self):
        #setup
        from adhocracy.model import Badge, CategoryBadge, DelegateableBadge, \
            InstanceBadge
        from adhocracy.model import UserBadge, Instance
        instance = Instance.find(u'test')
        # create for each type a global scope and an instance scope badge
        InstanceBadge.create(u'badge ü', u'#ccc', u'description ü')
        InstanceBadge.create(u'badge ü',
                             u'#ccc',
                             u'description ü',
                             instance=instance)
        UserBadge.create(u'badge ü', u'#ccc', u'description ü')
        UserBadge.create(u'ü', u'#ccc', u'ü', instance=instance)
        DelegateableBadge.create(u'badge ü', u'#ccc', u'description ü')
        DelegateableBadge.create(u'badge ü',
                                 u'#ccc',
                                 u'description ü',
                                 instance=instance)
        CategoryBadge.create(u'badge ü', u'#ccc', u"desc")
        CategoryBadge.create(u'badge ü', u'#ccc', u"desc", instance=instance)

        # all instance badges
        self.assert_(len(InstanceBadge.all()) == 1)
        self.assert_(len(InstanceBadge.all(instance=instance)) == 1)
        # all delegateable badges
        self.assert_(len(DelegateableBadge.all()) == 1)
        self.assert_(len(DelegateableBadge.all(instance=instance)) == 1)
        # all delegateable category badges
        self.assert_(len(CategoryBadge.all()) == 1)
        self.assert_(len(CategoryBadge.all(instance=instance)) == 1)
        # all user badgets
        self.assert_(len(UserBadge.all()) == 1)
        self.assert_(len(UserBadge.all(instance=instance)) == 1)
        # We can get all Badges by using `Badge`
        self.assert_(len(Badge.all()) == 4)
        self.assert_(len(Badge.all(instance=instance)) == 4)

        self.assert_(len(Badge.all_q().all()) == 8)
Beispiel #41
0
 def test_to_dict(self):
     from adhocracy.model import Instance
     test_instance = Instance.find('test')
     shouldbe = {'activation_delay': 7,
                 'allow_adopt': True,
                 'allow_delegate': True,
                 'allow_index': True,
                 'allow_propose': True,
                 'allow_thumbnailbadges': True,
                 'create_time': test_instance.create_time,
                 'creator': u'admin',
                 'default_group': u'voter',
                 'hidden': False,
                 'id': 1,
                 'instance_url': u'http://test.test.lan/instance/test',
                 'key': u'test',
                 'label': u'Test Instance',
                 'required_majority': 0.66,
                 'thumbnailbadges_height': None,
                 'thumbnailbadges_width': None,
                 'url': u'http://test.test.lan/instance/test'}
     result = test_instance.to_dict()
     self.assertEqual(shouldbe, result)