Пример #1
0
def test_dependencies():
    """Expect nonexistent trees to depend on their predecessor, associated
    rule changes and version files. Shouldn't add dependencies for the
    first version, if missing"""
    versions = [Version(str(i)*3, date(2001, i, i), date(2002, i, i))
                for i in range(1, 7)]
    parents = Version.parents_of(versions)
    tree_dir = entry.Tree('12', '1000')
    notice_dir = entry.Notice()
    vers_dir = entry.Version('12', '1000')
    # Existing trees
    (tree_dir / '222').write(Node())
    (tree_dir / '555').write(Node())

    deps = fill_with_rules.dependencies(tree_dir, vers_dir,
                                        list(zip(versions, parents)))

    # First is skipped, as we can't build it from a rule
    assert str(tree_dir / '111') not in deps
    # Second can also be skipped as a tree already exists
    assert deps.dependencies(str(tree_dir / '222')) == []
    # Third relies on the associated versions and the second tree
    expected = {str(tree_dir / '222'), str(notice_dir / '333'),
                str(vers_dir / '333')}
    assert set(deps.dependencies(str(tree_dir / '333'))) == expected
    # Fourth relies on the third, even though it's not been built
    expected = {str(tree_dir / '333'), str(notice_dir / '444'),
                str(vers_dir / '444')}
    assert set(deps.dependencies(str(tree_dir / '444'))) == expected
    # Fifth can be skipped as the tree already exists
    assert deps.dependencies(str(tree_dir / '555')) == []
    # Six relies on the fifth
    expected = {str(tree_dir / '555'), str(notice_dir / '666'),
                str(vers_dir / '666')}
    assert set(deps.dependencies(str(tree_dir / '666'))) == expected
    def test_dependencies(self):
        """Expect nonexistent trees to depend on their predecessor, associated
        rule changes and version files. Shouldn't add dependencies for the
        first version, if missing"""
        with self.cli.isolated_filesystem():
            version_ids = ['111', '222', '333', '444', '555', '666']
            tree_dir = entry.Tree('12', '1000')
            rule_dir = entry.RuleChanges()
            vers_dir = entry.Version('12', '1000')
            # Existing trees
            (tree_dir / '222').write(Node())
            (tree_dir / '555').write(Node())

            deps = fill_with_rules.dependencies(
                tree_dir, version_ids, '12', '1000')
            with deps.dependency_db() as db:
                graph = dict(db)    # copy

            # First is skipped, as we can't build it from a rule
            self.assertNotIn(str(tree_dir / '111'), graph)
            # Second can also be skipped as a tree already exists
            self.assertNotIn(str(tree_dir / '222'), graph)
            # Third relies on the associated versions and the second tree
            self.assertEqual(
                graph[str(tree_dir / '333')],
                set([str(tree_dir / '222'),
                     str(rule_dir / '333'),
                     str(vers_dir / '333')]))
            # Fourth relies on the third, even though it's not been built
            self.assertEqual(
                graph[str(tree_dir / '444')],
                set([str(tree_dir / '333'),
                     str(rule_dir / '444'),
                     str(vers_dir / '444')]))
            # Fifth can be skipped as the tree already exists
            self.assertNotIn(str(tree_dir / '555'), graph)
            # Six relies on the fifth
            self.assertEqual(
                graph[str(tree_dir / '666')],
                set([str(tree_dir / '555'),
                     str(rule_dir / '666'),
                     str(vers_dir / '666')]))
Пример #3
0
    def test_dependencies(self):
        """Expect nonexistent trees to depend on their predecessor, associated
        rule changes and version files. Shouldn't add dependencies for the
        first version, if missing"""
        with self.cli.isolated_filesystem():
            version_ids = ['111', '222', '333', '444', '555', '666']
            tree_dir = entry.Tree('12', '1000')
            rule_dir = entry.RuleChanges()
            vers_dir = entry.Version('12', '1000')
            # Existing trees
            (tree_dir / '222').write(Node())
            (tree_dir / '555').write(Node())

            deps = fill_with_rules.dependencies(tree_dir, version_ids, '12',
                                                '1000')

            # First is skipped, as we can't build it from a rule
            self.assertNotIn(str(tree_dir / '111'), deps)
            # Second can also be skipped as a tree already exists
            self.assertEqual(deps.dependencies(str(tree_dir / '222')), [])
            # Third relies on the associated versions and the second tree
            self.assertItemsEqual(deps.dependencies(str(tree_dir / '333')), [
                str(tree_dir / '222'),
                str(rule_dir / '333'),
                str(vers_dir / '333')
            ])
            # Fourth relies on the third, even though it's not been built
            self.assertItemsEqual(deps.dependencies(str(tree_dir / '444')), [
                str(tree_dir / '333'),
                str(rule_dir / '444'),
                str(vers_dir / '444')
            ])
            # Fifth can be skipped as the tree already exists
            self.assertEqual(deps.dependencies(str(tree_dir / '555')), [])
            # Six relies on the fifth
            self.assertItemsEqual(deps.dependencies(str(tree_dir / '666')), [
                str(tree_dir / '555'),
                str(rule_dir / '666'),
                str(vers_dir / '666')
            ])