def test_process_if_needed_missing_dependency_error():
    """If the annual XML or version isn't present, we should see a dependency
    error."""
    last_versions = [annual_editions.LastVersionInYear('1111', 2000)]

    with pytest.raises(dependency.Missing):
        annual_editions.process_if_needed('12', '1000', last_versions)

    entry.Version('12', '1000', '1111').write(
        Version('1111', date(2000, 1, 1), Citation(1, 1)))

    with pytest.raises(dependency.Missing):
        annual_editions.process_if_needed('12', '1000', last_versions)
def test_process_if_needed_missing_dependency_error():
    """If the annual XML or version isn't present, we should see a dependency
    error."""
    last_versions = [annual_editions.LastVersionInYear('1111', 2000)]

    with pytest.raises(dependency.Missing):
        annual_editions.process_if_needed('12', '1000', last_versions)

    entry.Version('12', '1000', '1111').write(
        Version('1111', date(2000, 1, 1), Citation(1, 1)))

    with pytest.raises(dependency.Missing):
        annual_editions.process_if_needed('12', '1000', last_versions)
Пример #3
0
    def test_process_if_needed_missing_dependency_error(self):
        """If the annual XML or version isn't present, we should see a
        dependency error."""
        with self.cli.isolated_filesystem():
            last_versions = [annual_editions.LastVersionInYear('1111', 2000)]

            with self.assertRaises(dependency.Missing):
                annual_editions.process_if_needed('12', '1000', last_versions)

            entry.Version('12', '1000', '1111').write(
                Version('1111', date(2000, 1, 1), date(2000, 1, 1)))

            with self.assertRaises(dependency.Missing):
                annual_editions.process_if_needed('12', '1000', last_versions)
    def test_process_if_needed_missing_dependency_error(self):
        """If the annual XML or version isn't present, we should see a
        dependency error."""
        with self.cli.isolated_filesystem():
            last_versions = [annual_editions.LastVersionInYear('1111', 2000)]

            with self.assertRaises(dependency.Missing):
                annual_editions.process_if_needed('12', '1000', last_versions)

            entry.Version('12', '1000', '1111').write(
                Version('1111', date(2000, 1, 1), date(2000, 1, 1)))

            with self.assertRaises(dependency.Missing):
                annual_editions.process_if_needed('12', '1000', last_versions)
def test_process_if_needed_missing_writes(monkeypatch):
    """If output isn't already present, we should process. If it is present,
    we don't need to, unless a dependency has changed."""
    monkeypatch.setattr(annual_editions, 'gpo_cfr', Mock())
    build_tree = annual_editions.gpo_cfr.builder.build_tree
    build_tree.return_value = Node()
    last_versions = [annual_editions.LastVersionInYear('1111', 2000)]
    entry.Version('12', '1000', '1111').write(
        Version('1111', date(2000, 1, 1), Citation(1, 1)))
    entry.Entry('annual', '12', '1000', 2000).write(b'<ROOT></ROOT>')

    annual_editions.process_if_needed('12', '1000', last_versions)
    assert build_tree.called

    build_tree.reset_mock()
    entry.Entry('tree', '12', '1000', '1111').write(b'tree-here')
    annual_editions.process_if_needed('12', '1000', last_versions)
    assert not build_tree.called

    # Simulate a change to an input file
    label_id = str(entry.Annual(12, 1000, 2000))
    new_time = timezone.now() + timedelta(hours=1)
    DBEntry.objects.filter(label_id=label_id).update(modified=new_time)
    annual_editions.process_if_needed('12', '1000', last_versions)
    assert build_tree.called
Пример #6
0
    def test_process_if_needed_missing_writes(self, xml_parser):
        """If output isn't already present, we should process. If it is
        present, we don't need to, unless a dependency has changed."""
        with self.cli.isolated_filesystem():
            build_tree = xml_parser.reg_text.build_tree
            build_tree.return_value = Node()
            last_versions = [annual_editions.LastVersionInYear('1111', 2000)]
            entry.Version('12', '1000', '1111').write(
                Version('1111', date(2000, 1, 1), date(2000, 1, 1)))
            entry.Entry('annual', '12', '1000', 2000).write(
                b'<ROOT></ROOT>')

            annual_editions.process_if_needed('12', '1000', last_versions)
            self.assertTrue(build_tree.called)

            build_tree.reset_mock()
            entry.Entry('tree', '12', '1000', '1111').write(b'tree-here')
            annual_editions.process_if_needed('12', '1000', last_versions)
            self.assertFalse(build_tree.called)

            # Simulate a change to an input file
            label_id = str(entry.Annual(12, 1000, 2000))
            new_time = timezone.now() + timedelta(hours=1)
            DBEntry.objects.filter(label_id=label_id).update(modified=new_time)
            annual_editions.process_if_needed('12', '1000', last_versions)
            self.assertTrue(build_tree.called)
    def test_process_if_needed_missing_writes(self, xml_parser):
        """If output isn't already present, we should process. If it is
        present, we don't need to, unless a dependency has changed."""
        with self.cli.isolated_filesystem():
            build_tree = xml_parser.reg_text.build_tree
            build_tree.return_value = Node()
            last_versions = [annual_editions.LastVersionInYear('1111', 2000)]
            entry.Version('12', '1000', '1111').write(
                Version('1111', date(2000, 1, 1), date(2000, 1, 1)))
            entry.Entry('annual', '12', '1000', 2000).write(
                '<ROOT></ROOT>')

            annual_editions.process_if_needed('12', '1000', last_versions)
            self.assertTrue(build_tree.called)

            build_tree.reset_mock()
            entry.Entry('tree', '12', '1000', '1111').write('tree-here')
            annual_editions.process_if_needed('12', '1000', last_versions)
            self.assertFalse(build_tree.called)

            # Simulate a change to an input file
            os.utime(str(entry.Annual('12', '1000', '2000')),
                     (time() + 1000, time() + 1000))
            annual_editions.process_if_needed('12', '1000', last_versions)
            self.assertTrue(build_tree.called)
def test_process_if_needed_missing_writes(monkeypatch):
    """If output isn't already present, we should process. If it is present,
    we don't need to, unless a dependency has changed."""
    monkeypatch.setattr(annual_editions, 'gpo_cfr', Mock())
    build_tree = annual_editions.gpo_cfr.builder.build_tree
    build_tree.return_value = Node()
    last_versions = [annual_editions.LastVersionInYear('1111', 2000)]
    entry.Version('12', '1000', '1111').write(
        Version('1111', date(2000, 1, 1), Citation(1, 1)))
    entry.Entry('annual', '12', '1000', 2000).write(b'<ROOT></ROOT>')

    annual_editions.process_if_needed('12', '1000', last_versions)
    assert build_tree.called

    build_tree.reset_mock()
    entry.Entry('tree', '12', '1000', '1111').write(b'tree-here')
    annual_editions.process_if_needed('12', '1000', last_versions)
    assert not build_tree.called

    # Simulate a change to an input file
    label_id = str(entry.Annual(12, 1000, 2000))
    new_time = timezone.now() + timedelta(hours=1)
    DBEntry.objects.filter(label_id=label_id).update(modified=new_time)
    annual_editions.process_if_needed('12', '1000', last_versions)
    assert build_tree.called
Пример #9
0
    def test_process_if_needed_missing_writes(self, xml_parser):
        """If output isn't already present, we should process. If it is
        present, we don't need to, unless a dependency has changed."""
        with self.cli.isolated_filesystem():
            build_tree = xml_parser.reg_text.build_tree
            build_tree.return_value = Node()
            last_versions = [annual_editions.LastVersionInYear('1111', 2000)]
            entry.Version('12', '1000', '1111').write(
                Version('1111', date(2000, 1, 1), date(2000, 1, 1)))
            entry.Entry('annual', '12', '1000', 2000).write(b'<ROOT></ROOT>')

            annual_editions.process_if_needed('12', '1000', last_versions)
            self.assertTrue(build_tree.called)

            build_tree.reset_mock()
            entry.Entry('tree', '12', '1000', '1111').write(b'tree-here')
            annual_editions.process_if_needed('12', '1000', last_versions)
            self.assertFalse(build_tree.called)

            # Simulate a change to an input file
            os.utime(str(entry.Annual('12', '1000', '2000')),
                     (time() + 1000, time() + 1000))
            annual_editions.process_if_needed('12', '1000', last_versions)
            self.assertTrue(build_tree.called)