Пример #1
0
def test_auto_add_nested(worktree, args):
    tmpdir = worktree.tmpdir
    foo = worktree.create_project("foo")
    bar = worktree.create_project("foo/bar")
    baz = tmpdir.mkdir("foo", "bar", "baz")
    qiproject_xml = baz.join("qiproject.xml")
    qiproject_xml.write("<project />")
    assert len(worktree.projects) == 2
    with qisys.sh.change_cwd(baz.strpath):
        args.projects = list()
        projects = qisys.parsers.get_projects(worktree, args)
        assert len(projects) == 1
        assert projects[0].src == "foo/bar/baz"
    assert len(worktree.projects) == 3

    # But, now a clever guy adds <project src="baz" /> in
    # bar/qiproject.xml:
    bar_qiproject = tmpdir.join("foo", "bar", "qiproject.xml")
    bar_qiproject.write("""
<project>
  <project src="baz" />
</project>
""")
    worktree2 = qisys.worktree.WorkTree(tmpdir.strpath)
    assert len(worktree2.projects) == 3
Пример #2
0
def test_auto_add_nested(worktree, args):
    tmpdir = worktree.tmpdir
    foo = worktree.create_project("foo")
    bar = worktree.create_project("foo/bar")
    baz = tmpdir.mkdir("foo", "bar", "baz")
    qiproject_xml = baz.join("qiproject.xml")
    qiproject_xml.write("<project />")
    assert len(worktree.projects) == 2
    with qisys.sh.change_cwd(baz.strpath):
        args.projects = list()
        projects = qisys.parsers.get_projects(worktree, args)
        assert len(projects) == 1
        assert projects[0].src == "foo/bar/baz"
    assert len(worktree.projects) == 3

    # But, now a clever guy adds <project src="baz" /> in
    # bar/qiproject.xml:
    bar_qiproject = tmpdir.join("foo", "bar", "qiproject.xml")
    bar_qiproject.write("""
<project>
  <project src="baz" />
</project>
""")
    worktree2 = qisys.worktree.WorkTree(tmpdir.strpath)
    assert len(worktree2.projects) == 3
Пример #3
0
def test_add_nested_projects(worktree):
    worktree.create_project("foo")
    tmpdir = worktree.tmpdir
    spam = tmpdir.mkdir("spam")
    spam.join("qiproject.xml").write(""" \
<project>
  <project src="eggs" />
</project>
""")
    spam.mkdir("eggs")
    worktree.add_project("spam")
    assert [p.src for p in worktree.projects] == ["foo", "spam", "spam/eggs"]

    worktree.remove_project("spam")
    assert [p.src for p in worktree.projects] == ["foo"]
Пример #4
0
def test_add_nested_projects(worktree):
    worktree.create_project("foo")
    tmpdir = worktree.tmpdir
    spam = tmpdir.mkdir("spam")
    spam.join("qiproject.xml").write(""" \
<project>
  <project src="eggs" />
</project>
""")
    spam.mkdir("eggs")
    worktree.add_project("spam")
    assert [p.src for p in worktree.projects] == ["foo", "spam", "spam/eggs"]

    worktree.remove_project("spam")
    assert [p.src for p in worktree.projects] == ["foo"]
Пример #5
0
def test_guess_current_project(worktree, args):
    """ Test Guess Current Project """
    libbar = worktree.create_project("lib/libbar")
    worktree.create_project("spam")
    worktree.create_project("spam/eggs")
    tmpdir = worktree.tmpdir
    # Simple check: when in the top dir of a project
    with qisys.sh.change_cwd(libbar.path):
        projects = qisys.parsers.get_projects(worktree, args)
        assert len(projects) == 1
        assert projects[0].src == "lib/libbar"
    # Should return the most nested project
    eggs_src = tmpdir.join("spam").join("eggs").mkdir("src")
    with qisys.sh.change_cwd(eggs_src.strpath):
        projects = qisys.parsers.get_projects(worktree, args)
        assert len(projects) == 1
        assert projects[0].src == "spam/eggs"
    # Should return None
    other = tmpdir.mkdir("other")
    with qisys.sh.change_cwd(other.strpath):
        assert not qisys.parsers.get_projects(worktree, args)
Пример #6
0
def test_guess_current_project(worktree, args):
    """ Test Guess Current Project """
    libbar = worktree.create_project("lib/libbar")
    worktree.create_project("spam")
    worktree.create_project("spam/eggs")
    tmpdir = worktree.tmpdir
    # Simple check: when in the top dir of a project
    with qisys.sh.change_cwd(libbar.path):
        projects = qisys.parsers.get_projects(worktree, args)
        assert len(projects) == 1
        assert projects[0].src == "lib/libbar"
    # Should return the most nested project
    eggs_src = tmpdir.join("spam").join("eggs").mkdir("src")
    with qisys.sh.change_cwd(eggs_src.strpath):
        projects = qisys.parsers.get_projects(worktree, args)
        assert len(projects) == 1
        assert projects[0].src == "spam/eggs"
    # Should return None
    other = tmpdir.mkdir("other")
    with qisys.sh.change_cwd(other.strpath):
        assert not qisys.parsers.get_projects(worktree, args)
Пример #7
0
def test_parse_one_arg(worktree, args):
    """ Test Parse One Arg """
    food = worktree.create_project("foo")
    # using '.' works
    with qisys.sh.change_cwd(food.path):
        args.projects = ['.']
        projects = qisys.parsers.get_projects(worktree, args)
        assert len(projects) == 1
        assert projects[0].src == "foo"
    # using a project src with an explicit worktree works
    args.worktree = worktree.root
    args.projects = ["foo"]
    projects = qisys.parsers.get_projects(worktree, args)
    assert len(projects) == 1
    assert projects[0].src == "foo"
Пример #8
0
def test_parse_one_arg(worktree, args):
    """ Test Parse One Arg """
    food = worktree.create_project("foo")
    # using '.' works
    with qisys.sh.change_cwd(food.path):
        args.projects = ['.']
        projects = qisys.parsers.get_projects(worktree, args)
        assert len(projects) == 1
        assert projects[0].src == "foo"
    # using a project src with an explicit worktree works
    args.worktree = worktree.root
    args.projects = ["foo"]
    projects = qisys.parsers.get_projects(worktree, args)
    assert len(projects) == 1
    assert projects[0].src == "foo"
Пример #9
0
def test_observers_are_notified(worktree):
    mock_observer = mock.Mock()
    worktree.register(mock_observer)
    worktree.create_project("foo")
    assert mock_observer.on_project_added.called
Пример #10
0
def test_observers_are_notified(worktree):
    mock_observer = mock.Mock()
    worktree.register(mock_observer)
    worktree.create_project("foo")
    assert mock_observer.on_project_added.called
Пример #11
0
def test_observers_are_notified(worktree):
    """ Test Observers Are Notified """
    mock_observer = mock.Mock()
    worktree.register(mock_observer)
    worktree.create_project("foo")
    assert mock_observer.reload.called