def test_enable_list_archiver(self):
     # When the system configuration file disables an archiver site-wide,
     # the list-specific mailing list will get initialized as not enabled.
     # Create the archiver set on the fly so that it doesn't get
     # initialized with a configuration that enables the prototype archiver.
     archiver_set = IListArchiverSet(self._mlist)
     archiver = archiver_set.get('prototype')
     self.assertFalse(archiver.is_enabled)
     # Enable both the list archiver and the system archiver.
     archiver.is_enabled = True
     config.push('enable prototype', """\
     [archiver.prototype]
     enable: yes
     """)
     # Get the IListArchiver again.
     archiver = archiver_set.get('prototype')
     self.assertTrue(archiver.is_enabled)
     config.pop('enable prototype')
Exemple #2
0
 def test_enable_list_archiver(self):
     # When the system configuration file disables an archiver site-wide,
     # the list-specific mailing list will get initialized as not enabled.
     # Create the archiver set on the fly so that it doesn't get
     # initialized with a configuration that enables the prototype archiver.
     archiver_set = IListArchiverSet(self._mlist)
     archiver = archiver_set.get('prototype')
     self.assertFalse(archiver.is_enabled)
     # Enable both the list archiver and the system archiver.
     archiver.is_enabled = True
     config.push('enable prototype', """\
     [archiver.prototype]
     enable: yes
     """)
     # Get the IListArchiver again.
     archiver = archiver_set.get('prototype')
     self.assertTrue(archiver.is_enabled)
     config.pop('enable prototype')
class TestListArchiver(unittest.TestCase):
    layer = ConfigLayer

    def setUp(self):
        self._mlist = create_list('*****@*****.**')
        self._set = IListArchiverSet(self._mlist)

    def test_list_archivers(self):
        # Find the set of archivers registered for this mailing list.
        self.assertEqual(['mail-archive', 'mhonarc', 'prototype'],
                         sorted(archiver.name
                                for archiver in self._set.archivers))

    def test_get_archiver(self):
        # Use .get() to see if a mailing list has an archiver.
        archiver = self._set.get('mhonarc')
        self.assertEqual(archiver.name, 'mhonarc')
        self.assertTrue(archiver.is_enabled)
        self.assertEqual(archiver.mailing_list, self._mlist)
        self.assertEqual(archiver.system_archiver.name, 'mhonarc')

    def test_get_archiver_no_such(self):
        # Using .get() on a non-existing name returns None.
        self.assertIsNone(self._set.get('no-such-archiver'))

    def test_site_disabled(self):
        # Here the system configuration enables all the archivers in time for
        # the archive set to be created with all list archivers enabled.  But
        # then the site-wide archiver gets disabled, so the list specific
        # archiver will also be disabled.
        archiver_set = IListArchiverSet(self._mlist)
        archiver = archiver_set.get('mhonarc')
        self.assertTrue(archiver.is_enabled)
        # Disable the site-wide archiver.
        config.push(
            'enable mhonarc', """\
        [archiver.mhonarc]
        enable: no
        """)
        self.assertFalse(archiver.is_enabled)
        config.pop('enable mhonarc')
class TestListArchiver(unittest.TestCase):
    layer = ConfigLayer

    def setUp(self):
        self._mlist = create_list('*****@*****.**')
        self._set = IListArchiverSet(self._mlist)

    def test_list_archivers(self):
        # Find the set of archivers registered for this mailing list.
        self.assertEqual(
            ['mail-archive', 'mhonarc', 'prototype'],
            sorted(archiver.name for archiver in self._set.archivers))

    def test_get_archiver(self):
        # Use .get() to see if a mailing list has an archiver.
        archiver = self._set.get('prototype')
        self.assertEqual(archiver.name, 'prototype')
        self.assertTrue(archiver.is_enabled)
        self.assertEqual(archiver.mailing_list, self._mlist)
        self.assertEqual(archiver.system_archiver.name, 'prototype')

    def test_get_archiver_no_such(self):
        # Using .get() on a non-existing name returns None.
        self.assertIsNone(self._set.get('no-such-archiver'))

    def test_site_disabled(self):
        # Here the system configuration enables all the archivers in time for
        # the archive set to be created with all list archivers enabled.  But
        # then the site-wide archiver gets disabled, so the list specific
        # archiver will also be disabled.
        archiver_set = IListArchiverSet(self._mlist)
        archiver = archiver_set.get('prototype')
        self.assertTrue(archiver.is_enabled)
        # Disable the site-wide archiver.
        config.push('enable prototype', """\
        [archiver.prototype]
        enable: no
        """)
        self.assertFalse(archiver.is_enabled)
        config.pop('enable prototype')
Exemple #5
0
class ArchiverGetterSetter(GetterSetter):
    """Resource for updating archiver statuses."""
    def __init__(self, mlist):
        super().__init__()
        self._archiver_set = IListArchiverSet(mlist)

    def put(self, mlist, attribute, value):
        # attribute will contain the (bytes) name of the archiver that is
        # getting a new status.  value will be the representation of the new
        # boolean status.
        archiver = self._archiver_set.get(attribute)
        assert archiver is not None, attribute
        archiver.is_enabled = as_boolean(value)
Exemple #6
0
class ArchiverGetterSetter(GetterSetter):
    """Resource for updating archiver statuses."""
    def __init__(self, mlist):
        super(ArchiverGetterSetter, self).__init__()
        self._archiver_set = IListArchiverSet(mlist)

    def put(self, mlist, attribute, value):
        # attribute will contain the (bytes) name of the archiver that is
        # getting a new status.  value will be the representation of the new
        # boolean status.
        archiver = self._archiver_set.get(attribute)
        if archiver is None:
            raise ValueError('No such archiver: {}'.format(attribute))
        archiver.is_enabled = as_boolean(value)
Exemple #7
0
class ArchiverGetterSetter(GetterSetter):
    """Resource for updating archiver statuses."""

    def __init__(self, mlist):
        super().__init__()
        self._archiver_set = IListArchiverSet(mlist)

    def put(self, mlist, attribute, value):
        # attribute will contain the (bytes) name of the archiver that is
        # getting a new status.  value will be the representation of the new
        # boolean status.
        archiver = self._archiver_set.get(attribute)
        assert archiver is not None, attribute
        archiver.is_enabled = as_boolean(value)
Exemple #8
0
 def test_site_disabled(self):
     # Here the system configuration enables all the archivers in time for
     # the archive set to be created with all list archivers enabled.  But
     # then the site-wide archiver gets disabled, so the list specific
     # archiver will also be disabled.
     archiver_set = IListArchiverSet(self._mlist)
     archiver = archiver_set.get('prototype')
     self.assertTrue(archiver.is_enabled)
     # Disable the site-wide archiver.
     config.push('enable prototype', """\
     [archiver.prototype]
     enable: no
     """)
     self.assertFalse(archiver.is_enabled)
     config.pop('enable prototype')
 def test_site_disabled(self):
     # Here the system configuration enables all the archivers in time for
     # the archive set to be created with all list archivers enabled.  But
     # then the site-wide archiver gets disabled, so the list specific
     # archiver will also be disabled.
     archiver_set = IListArchiverSet(self._mlist)
     archiver = archiver_set.get('prototype')
     self.assertTrue(archiver.is_enabled)
     # Disable the site-wide archiver.
     config.push('enable prototype', """\
     [archiver.prototype]
     enable: no
     """)
     self.assertFalse(archiver.is_enabled)
     config.pop('enable prototype')
Exemple #10
0
class ArchiverGetterSetter(GetterSetter):
    """Resource for updating archiver statuses."""

    def __init__(self, mlist):
        super(ArchiverGetterSetter, self).__init__()
        self._archiver_set = IListArchiverSet(mlist)

    def put(self, mlist, attribute, value):
        # attribute will contain the (bytes) name of the archiver that is
        # getting a new status.  value will be the representation of the new
        # boolean status.
        archiver = self._archiver_set.get(attribute.decode('utf-8'))
        if archiver is None:
            raise ValueError('No such archiver: {}'.format(attribute))
        archiver.is_enabled = as_boolean(value)