def test_write_to_disk_no_effective(self):
     """If a version is somehow associated with a proposed rule (or a final
     rule has been misparsed), we should get an exception"""
     xml = Mock()
     xml.effective = None
     with self.assertRaises(versions.InvalidEffectiveDate):
         versions.write_to_disk(xml, entry.Version('12', '1000', '11'))
 def test_write_to_disk_no_effective(self):
     """If a version is somehow associated with a proposed rule (or a final
     rule has been misparsed), we should get an exception"""
     xml = Mock()
     xml.effective = None
     with self.assertRaises(versions.InvalidEffectiveDate):
         versions.write_to_disk(xml, entry.Version('12', '1000', '11'))
示例#3
0
def test_write_to_disk_no_effective(monkeypatch):
    """If a version is somehow associated with a proposed rule (or a final
    rule has been misparsed), we should get a warning"""
    xml = Mock(effective=None, version_id='vv123')
    monkeypatch.setattr(versions, 'logger', Mock())

    versions.write_to_disk(xml, entry.Version('12', '1000', '11'))

    assert versions.logger.warning.called
    assert 'vv123' in versions.logger.warning.call_args[0]
def test_write_to_disk_no_effective(monkeypatch):
    """If a version is somehow associated with a proposed rule (or a final
    rule has been misparsed), we should get a warning"""
    xml = Mock(effective=None, version_id='vv123')
    monkeypatch.setattr(versions, 'logger', Mock())

    versions.write_to_disk(xml, entry.Version('12', '1000', '11'))

    assert versions.logger.warning.called
    assert 'vv123' in versions.logger.warning.call_args[0]
def test_write_to_disk():
    """If a version has been delayed, its effective date should be part of the
    serialized json"""
    xml = Mock(effective=date(2002, 2, 2),
               version_id='111',
               fr_citation=Citation(1, 1))
    path = entry.Version('12', '1000')
    versions.write_to_disk(xml, path / '111')

    xml.version_id = '222'
    versions.write_to_disk(xml, path / '222',
                           versions.Delay(by='333', until=date(2004, 4, 4)))

    assert (path / '111').read().effective == date(2002, 2, 2)
    assert (path / '222').read().effective == date(2004, 4, 4)
def test_write_to_disk():
    """If a version has been delayed, its effective date should be part of the
    serialized json"""
    xml = Mock(effective=date(2002, 2, 2), version_id='111',
               fr_citation=Citation(1, 1))
    path = entry.Version('12', '1000')
    versions.write_to_disk(xml, path / '111')

    xml.version_id = '222'
    versions.write_to_disk(
        xml, path / '222',
        versions.Delay(by='333', until=date(2004, 4, 4)))

    assert (path / '111').read().effective == date(2002, 2, 2)
    assert (path / '222').read().effective == date(2004, 4, 4)
    def test_write_to_disk(self):
        """If a version has been delayed, its effective date should be part of
        the serialized json"""
        xml = Mock()
        path = entry.Version('12', '1000')
        with self.cli.isolated_filesystem():
            xml.configure_mock(effective=date(2002, 2, 2), version_id='111',
                               published=date(2002, 1, 1))
            versions.write_to_disk(xml, path / '111')

            xml.configure_mock(version_id='222')
            versions.write_to_disk(
                xml, path / '222',
                versions.Delay(by='333', until=date(2004, 4, 4)))

            self.assertEqual((path / '111').read().effective, date(2002, 2, 2))
            self.assertEqual((path / '222').read().effective, date(2004, 4, 4))
    def test_write_to_disk(self):
        """If a version has been delayed, its effective date should be part of
        the serialized json"""
        xml = Mock()
        path = entry.Version('12', '1000')
        with self.cli.isolated_filesystem():
            xml.configure_mock(effective=date(2002, 2, 2), version_id='111',
                               published=date(2002, 1, 1))
            versions.write_to_disk(xml, path / '111')

            xml.configure_mock(version_id='222')
            versions.write_to_disk(
                xml, path / '222',
                versions.Delay(by='333', until=date(2004, 4, 4)))

            self.assertEqual((path / '111').read().effective, date(2002, 2, 2))
            self.assertEqual((path / '222').read().effective, date(2004, 4, 4))