예제 #1
0
 def test_icon_url_contains_mtime(self):
     with self.mocked_path_func:
         from adhocracy.lib import helpers as h
         from adhocracy.tests.testtools import tt_get_instance
         test_instance = tt_get_instance()
         url = h.instance.icon_url(test_instance, 48)
         self.assertEqual(
             url, 'http://test.test.lan/instance/test_48.png?t=1234')
 def setUp(self):
     self.me = tt_make_user()
     self.first = tt_make_user()
     self.second = tt_make_user()
     self.proposal = tt_make_proposal(voting=True)
     self.poll = Poll.create(self.proposal, self.proposal.creator,
                             Poll.ADOPT)
     self.instance = tt_get_instance()
예제 #3
0
파일: test_url.py 프로젝트: alkadis/vcv
 def test_icon_url_with_y(self):
     with self.mocked_path_func:
         from adhocracy.lib import helpers as h
         from adhocracy.tests.testtools import tt_get_instance
         test_instance = tt_get_instance()
         url = h.logo_url(test_instance, 48)
         self.assertEqual(
             url, 'http://test.test.lan/instance/test_48.png?t=1234')
예제 #4
0
파일: test_url.py 프로젝트: alkadis/vcv
 def test_icon_url_with_x_and_y(self):
     with self.mocked_path_func:
         from adhocracy.lib import helpers as h
         from adhocracy.tests.testtools import tt_get_instance
         test_instance = tt_get_instance()
         url = h.logo_url(test_instance, 48, x=11)
         self.assertEqual(
             url, 'http://test.test.lan/instance/test_11x48.png?t=1234')
 def setUp(self):
     self.me = tt_make_user()
     self.first = tt_make_user()
     self.second = tt_make_user()
     self.proposal = tt_make_proposal(voting=True)
     self.poll = Poll.create(self.proposal, self.proposal.creator,
                             Poll.ADOPT)
     self.instance = tt_get_instance()
예제 #6
0
파일: test_user.py 프로젝트: alkadis/vcv
 def test_delete_user_deletes_watches(self):
     from adhocracy.model import Watch
     voter_group = Group.by_code(Group.CODE_VOTER)
     user = tt_make_user(instance_group=voter_group)
     instance = tt_get_instance()
     watch = Watch.create(user, instance)
     self.assertFalse(watch.is_deleted())
     user.delete()
     self.assertTrue(watch.is_deleted())
예제 #7
0
 def test_delete_user_deletes_watches(self):
     from adhocracy.model import Watch
     voter_group = Group.by_code(Group.CODE_VOTER)
     user = tt_make_user(instance_group=voter_group)
     instance = tt_get_instance()
     watch = Watch.create(user, instance)
     self.assertFalse(watch.is_deleted())
     user.delete()
     self.assertTrue(watch.is_deleted())
예제 #8
0
    def setUp(self):
        self.me = tt_make_user(name='me')
        self.high_delegate = tt_make_user(name='high_delegate')
        self.low_delegate = tt_make_user(name='low_delegate')

        self.proposal = tt_make_proposal(creator=self.me, voting=True)
        self.poll = Poll.create(self.proposal, self.proposal.creator,
                                Poll.ADOPT)
        self.decision = Decision(self.me, self.poll)
        self.instance = tt_get_instance()
예제 #9
0
    def setUp(self):
        super(TestDecisionWithDelegation, self).setUp()
        self.me = tt_make_user(name='me')
        self.high_delegate = tt_make_user(name='high_delegate')
        self.low_delegate = tt_make_user(name='low_delegate')

        self.proposal = tt_make_proposal(creator=self.me, voting=True)
        self.poll = Poll.create(self.proposal, self.proposal.creator,
                                Poll.ADOPT)
        self.decision = Decision(self.me, self.poll)
        self.instance = tt_get_instance()
예제 #10
0
    def _make_norm(self, proposal, creator):
        from adhocracy import model

        instance = tt_get_instance()
        page = model.Page.create(instance,
                                 title=tt_make_str(),
                                 text=tt_make_str(),
                                 creator=creator)
        selection = model.Selection.create(proposal, page, creator)
        selection.variant_poll(page.head)
        return page
예제 #11
0
    def _make_norm(self, proposal, creator):
        from adhocracy import model

        instance = tt_get_instance()
        page = model.Page.create(instance,
                                 title=tt_make_str(),
                                 text=tt_make_str(),
                                 creator=creator)
        selection = model.Selection.create(proposal, page, creator)
        selection.variant_poll(page.head)
        return page
예제 #12
0
    def test_valid_category_badge(self):
        from formencode import Invalid
        from adhocracy.forms import ValidCategoryBadge
        from adhocracy.model import CategoryBadge, instance_filter

        # the currently set instance ist the test instance. CategoryBadges from
        # the current instance are valid.
        test_instance = tt_get_instance()
        self.assertEqual(test_instance, instance_filter.get_instance())
        test_category = CategoryBadge.create("test_category", "#ccc", "description", test_instance)
        value = ValidCategoryBadge.to_python(str(test_category.id))
        self.assertEqual(value, test_category)

        # from other instances they are not valid
        other_instance = tt_make_instance("other", "Other Instance")
        other_category = CategoryBadge.create("other_category", "#ccc", "description", other_instance)
        self.assertRaises(Invalid, ValidCategoryBadge.to_python, str(other_category.id))
    def test_detach(self):
        proposal = tt_make_proposal(voting=True)
        user1 = tt_make_user()
        user2 = tt_make_user()
        user3 = tt_make_user()

        d2to1 = Delegation(user2, user1, proposal)
        model.meta.Session.add(d2to1)

        d3to1 = Delegation(user3, user1, proposal)
        model.meta.Session.add(d3to1)
        model.meta.Session.flush()

        dn = DelegationNode(user1, proposal)
        assert len(dn.inbound()) == 2

        user1.revoke_delegations(tt_get_instance())

        dn = DelegationNode(user1, proposal)
        assert len(dn.inbound()) == 0
    def test_detach(self):
        proposal = tt_make_proposal(voting=True)
        user1 = tt_make_user()
        user2 = tt_make_user()
        user3 = tt_make_user()

        d2to1 = Delegation(user2, user1, proposal)
        model.meta.Session.add(d2to1)

        d3to1 = Delegation(user3, user1, proposal)
        model.meta.Session.add(d3to1)
        model.meta.Session.flush()

        dn = DelegationNode(user1, proposal)
        assert len(dn.inbound()) == 2

        user1.revoke_delegations(tt_get_instance())

        dn = DelegationNode(user1, proposal)
        assert len(dn.inbound()) == 0
예제 #15
0
    def test_valid_category_badge(self):
        from formencode import Invalid
        from adhocracy.forms import ValidCategoryBadge
        from adhocracy.model import CategoryBadge, instance_filter

        # the currently set instance ist the test instance. CategoryBadges from
        # the current instance are valid.
        test_instance = tt_get_instance()
        self.assertEqual(test_instance, instance_filter.get_instance())
        test_category = CategoryBadge.create('test_category', '#ccc',
                                             'description', test_instance)
        value = ValidCategoryBadge.to_python(str(test_category.id))
        self.assertEqual(value, test_category)

        # from other instances they are not valid
        other_instance = tt_make_instance('other', 'Other Instance')
        other_category = CategoryBadge.create('other_category', '#ccc',
                                              'description', other_instance)
        self.assertRaises(Invalid, ValidCategoryBadge.to_python,
                          str(other_category.id))