Exemplo n.º 1
0
    def test_get_maintainers_returns_correct_dict_from_real_maintainers(self):
        loc = self.loc
        user = self.create_user()

        loc.maintainer.add(user)
        actual = get_maintainers_description_for_location(loc)

        expected = [{'user': user, 'temporary': False}]
        self.assertEqual(actual, expected)
        self.assertEqual(get_maintainers_for_location(loc)[0], user)
Exemplo n.º 2
0
    def test_get_maintainers_returns_correct_dict_from_real_maintainers(self):
        loc = self.loc
        user = self.create_user()

        loc.maintainer.add(user)
        actual = get_maintainers_description_for_location(loc)

        expected = [ {'user':user, 'temporary':False} ]
        self.assertEqual(actual, expected)
        self.assertEqual(get_maintainers_for_location(loc)[0], user)
Exemplo n.º 3
0
    def test_get_maintainers_returns_dict_containing_all_temporary_maintainers(self):
        loc = self.loc
        user = self.create_user()
        tmpusers = [self.create_user(), self.create_user()]

        loc.maintainer.add(user)
        tmploc = self.create_tmploc(loc, tmpusers)
        actual = get_maintainers_description_for_location(loc)

        expected = [ {'user':u, 'temporary':True} for u in tmpusers ] + [ {'user':user, 'temporary':False} ]
        self.assertSetEqual(actual, expected)
Exemplo n.º 4
0
    def test_get_maintainers_returns_temporary_maintainer(self):
        tmpuser = self.create_user()
        tmploc = self.create_tmploc(self.loc, [tmpuser])

        self.assertEqual(tmploc.maintainer.count(), 1)
        self.assertEqual(self.loc, tmploc.location)

        actual = get_maintainers_description_for_location(self.loc)
        expected = [{'user': tmpuser, 'temporary': True}]

        self.assertEqual(actual, expected)
        self.assertEqual(get_maintainers_for_location(self.loc)[0], tmpuser)
Exemplo n.º 5
0
    def test_get_maintainers_returns_temporary_maintainer(self):
        tmpuser = self.create_user()
        tmploc = self.create_tmploc(self.loc, [tmpuser])

        self.assertEqual(tmploc.maintainer.count(), 1)
        self.assertEqual(self.loc, tmploc.location)

        actual = get_maintainers_description_for_location(self.loc)
        expected = [ {'user':tmpuser, 'temporary':True} ]

        self.assertEqual(actual, expected)
        self.assertEqual(get_maintainers_for_location(self.loc)[0], tmpuser)
Exemplo n.º 6
0
    def test_removing_maintainer_for_location_by_permitted_user(self):
        '''
        If user is not location's real maintainer, then he cannot remove temporary maintainers for this location.
        '''
        location = self.loc
        maintainer = self.create_user('main')
        remover = self.create_user('remover')
        location.maintainer.add(remover)
        tmploc = self.create_tmploc(location, [maintainer])

        remove_temporary_maintainer_from_location(tmploc, maintainer, remover)

        maintainers = get_maintainers_description_for_location(location)
        self.assertNotIn({'user': maintainer, 'temporary': True}, maintainers)
        self.assertNotIn(maintainer, maintainers)
Exemplo n.º 7
0
    def test_adding_maintainer_for_location_by_permitted_user(self):
        '''
        If user is not location's real maintainer, then he cannot add temporary maintainers for this location.
        '''
        location = self.loc
        maintainer = self.create_user()
        adder = self.create_user('adder')
        location.maintainer.add(adder)
        tmplocation = self.create_tmploc(location, [])

        add_temporary_maintainer_for_location(tmplocation, maintainer, adder)

        maintainers = get_maintainers_description_for_location(location)
        self.assertIn({'user': maintainer, 'temporary': True}, maintainers)
        self.assertIn(maintainer, get_maintainers_for_location(location))
Exemplo n.º 8
0
    def test_removing_maintainer_for_location_by_permitted_user(self):
        '''
        If user is not location's real maintainer, then he cannot remove temporary maintainers for this location.
        '''
        location = self.loc
        maintainer = self.create_user('main')
        remover = self.create_user('remover')
        location.maintainer.add(remover)
        tmploc = self.create_tmploc(location, [maintainer])

        remove_temporary_maintainer_from_location(tmploc, maintainer, remover)

        maintainers = get_maintainers_description_for_location(location)
        self.assertNotIn( {'user':maintainer, 'temporary':True}, maintainers)
        self.assertNotIn( maintainer, maintainers )
Exemplo n.º 9
0
    def test_adding_maintainer_for_location_by_permitted_user(self):
        '''
        If user is not location's real maintainer, then he cannot add temporary maintainers for this location.
        '''
        location = self.loc
        maintainer = self.create_user()
        adder = self.create_user('adder')
        location.maintainer.add(adder)
        tmplocation = self.create_tmploc(location, [])

        add_temporary_maintainer_for_location(tmplocation, maintainer, adder)

        maintainers = get_maintainers_description_for_location(location)
        self.assertIn( {'user':maintainer, 'temporary':True}, maintainers)
        self.assertIn( maintainer, get_maintainers_for_location(location) )
Exemplo n.º 10
0
    def test_get_maintainers_returns_dict_containing_all_temporary_maintainers(
            self):
        loc = self.loc
        user = self.create_user()
        tmpusers = [self.create_user(), self.create_user()]

        loc.maintainer.add(user)
        tmploc = self.create_tmploc(loc, tmpusers)
        actual = get_maintainers_description_for_location(loc)

        expected = [{
            'user': u,
            'temporary': True
        } for u in tmpusers] + [{
            'user': user,
            'temporary': False
        }]
        self.assertSetEqual(actual, expected)