コード例 #1
0
ファイル: cli_unit_tests.py プロジェクト: JIC-CSB/jicagile
 def test_run(self):
     from jicagile.cli import CLI
     cli = CLI()
     args = MagicMock()
     args.command = "dummy"
     cli.dummy = MagicMock()
     cli.run(args)
     cli.dummy.assert_called_once_with(args)
コード例 #2
0
ファイル: functional_tests.py プロジェクト: JIC-CSB/jicagile
    def test_teammember_command(self):
        from jicagile.cli import CLI
        from jicagile.config import Team

        cli = CLI()

        # No .themes.yml file exists yet.
        team_fpath = os.path.join(self.tmp_dir, ".team.yml")
        self.assertFalse(os.path.isfile(team_fpath))

        args = cli.parse_args(["teammember", "add", "TO", "Tjelvar", "Olsson"])
        cli.run(args)
        self.assertTrue(os.path.isfile(team_fpath))
        team = Team.from_file(team_fpath)
        self.assertEqual(len(team), 1)
        self.assertEqual(team["TO"].first_name, "Tjelvar")
        self.assertEqual(team["TO"].last_name, "Olsson")

        args = cli.parse_args(["teammember", "add", "MH", "Matthew", "Hartley"])
        cli.run(args)
        team = Team.from_file(team_fpath)
        self.assertEqual(len(team), 2)

        args = cli.parse_args(["teammember", "rm", "TO"])
        cli.run(args)
        team = Team.from_file(team_fpath)
        self.assertEqual(len(team), 1)
        self.assertFalse("TO" in team)
        self.assertTrue("MH" in team)

        args = cli.parse_args(["teammember", "rm", "TO"])
        cli.run(args)
コード例 #3
0
ファイル: functional_tests.py プロジェクト: JIC-CSB/jicagile
    def test_theme_command(self):
        from jicagile.cli import CLI
        from jicagile.config import Themes

        cli = CLI()

        # No .themes.yml file exists yet.
        themes_fpath = os.path.join(self.tmp_dir, ".themes.yml")
        self.assertFalse(os.path.isfile(themes_fpath))

        args = cli.parse_args(["theme", "add", "admin", "stuff we need to do"])
        cli.run(args)
        self.assertTrue(os.path.isfile(themes_fpath))
        themes = Themes.from_file(themes_fpath)
        self.assertEqual(len(themes), 1)
        self.assertEqual(themes["admin"].description, "stuff we need to do")

        args = cli.parse_args(["theme", "add", "sysadmin", "configure servers"])
        cli.run(args)
        themes = Themes.from_file(themes_fpath)
        self.assertEqual(len(themes), 2)

        args = cli.parse_args(["theme", "rm", "admin"])
        cli.run(args)
        themes = Themes.from_file(themes_fpath)
        self.assertEqual(len(themes), 1)
        self.assertFalse("admin" in themes)
        self.assertTrue("sysadmin" in themes)

        args = cli.parse_args(["theme", "rm", "admin"])
        cli.run(args)
コード例 #4
0
ファイル: functional_tests.py プロジェクト: JIC-CSB/jicagile
    def test_add_to_current(self):
        import jicagile
        from jicagile.cli import CLI

        cli = CLI()
        args = cli.parse_args(["add", "-c", "Basic task", "1"])
        cli.run(args)

        current_todo_dir = os.path.join(self.tmp_dir, "current", "todo")
        task_fpath = os.path.join(current_todo_dir, "basic-task.yml")
        self.assertTrue(os.path.isfile(task_fpath))

        task_from_file = jicagile.Task.from_file(task_fpath)
        self.assertEqual(task_from_file["title"], "Basic task")
        self.assertEqual(task_from_file["storypoints"], 1)
コード例 #5
0
ファイル: functional_tests.py プロジェクト: JIC-CSB/jicagile
    def test_mv(self):
        import jicagile
        from jicagile.cli import CLI

        cli = CLI()
        args = cli.parse_args(["add", "Basic task", "1"])
        cli.run(args)

        src_fpath = os.path.join("backlog", "basic-task.yml")
        todo = os.path.join("current", "todo")
        dest_fpath = os.path.join(todo, "basic-task.yml")

        self.assertTrue(os.path.isfile(src_fpath))

        args = cli.parse_args(["mv", src_fpath, todo])
        cli.run(args)

        self.assertFalse(os.path.isfile(src_fpath))
        self.assertTrue(os.path.isfile(dest_fpath))
コード例 #6
0
ファイル: functional_tests.py プロジェクト: JIC-CSB/jicagile
    def test_add_with_theme(self):
        import jicagile
        from jicagile.cli import CLI

        cli = CLI()

        themes = jicagile.config.Themes()
        themes.add_member("admin", "grants, appraisals, etc")
        cli.project.themes = themes

        args = cli.parse_args(["add", "Basic task", "1", "-e", "admin"])
        cli.run(args)

        backlog_dir = os.path.join(self.tmp_dir, "backlog")
        task_fpath = os.path.join(backlog_dir, "basic-task.yml")
        self.assertTrue(os.path.isfile(task_fpath))

        task_from_file = jicagile.Task.from_file(task_fpath)
        self.assertEqual(task_from_file["theme"], "admin")
コード例 #7
0
ファイル: functional_tests.py プロジェクト: JIC-CSB/jicagile
    def test_list_backlog_with_trailing_slash(self):
        import jicagile
        from jicagile.cli import CLI

        cli = CLI()
        args = cli.parse_args(["add", "Basic task", "1"])
        cli.run(args)

        backlog_dir = os.path.join(self.tmp_dir, "backlog/")
        args = cli.parse_args(["list", backlog_dir])
        with capture_sys_output() as (stdout, stderr):
            cli.run(args)
            text = ansi_escape.sub("", stdout.getvalue())
            expected = """# BACKLOG [1]

## None's tasks [1]

[] Basic task [1]
"""
            self.assertEqual(text, expected, "\n" + text + expected)
コード例 #8
0
ファイル: functional_tests.py プロジェクト: JIC-CSB/jicagile
    def test_add_to_empty(self):
        from jicagile.cli import CLI
        from jicagile.config import Themes

        cli = CLI()

        # Add one to create the .theme.yml file.
        args = cli.parse_args(["theme", "add", "admin", "stuff we need to do"])
        cli.run(args)

        # Remove it to create an empty file.
        args = cli.parse_args(["theme", "rm", "admin"])
        cli.run(args)

        # Add something to the empty file.
        args = cli.parse_args(["theme", "add", "admin", "stuff we need to do"])
        cli.run(args)
コード例 #9
0
ファイル: functional_tests.py プロジェクト: JIC-CSB/jicagile
    def test_list(self):
        import jicagile
        from jicagile.cli import CLI

        cli = CLI()
        args = cli.parse_args(["add", "Basic task", "1"])
        cli.run(args)

        backlog_dir = os.path.join(self.tmp_dir, "backlog")
        args = cli.parse_args(["list", backlog_dir])
        with capture_sys_output() as (stdout, stderr):
            cli.run(args)
            text = ansi_escape.sub("", stdout.getvalue())
            expected = """# BACKLOG [1]

## None's tasks [1]

[] Basic task [1]
"""
            self.assertEqual(text, expected, "\n" + text + expected)

        team = jicagile.config.Team()
        team.add_member("TO", "Tjelvar", "Olsson")
        team.add_member("MH", "Matthew", "Hartley")
        cli.project.team = team

        themes = jicagile.config.Themes()
        themes.add_member("admin", "forms etc")
        themes.add_member("fun", "programming etc")
        cli.project.themes = themes

        args = cli.parse_args(["add", "Have fun", "1", "-p", "TO", "-e", "fun", "-c"])
        cli.run(args)
        args = cli.parse_args(["add", "Email people", "1", "-p", "TO", "-e", "admin", "-c"])
        cli.run(args)
        args = cli.parse_args(["add", "Attempt to fill in appriasal form", "5", "-p", "TO", "-e", "admin", "-c"])
        cli.run(args)
        args = cli.parse_args(["add", "Other stuff", "1", "-p", "TO", "-c"])
        cli.run(args)
        args = cli.parse_args(["add", "Management stuff", "8", "-p", "MH", "-e", "admin", "-c"])
        cli.run(args)

        args = cli.parse_args(["list", "todo"])
        with capture_sys_output() as (stdout, stderr):
            cli.run(args)
            text = ansi_escape.sub("", stdout.getvalue())
            expected = """# TODO [16]

## Matthew's tasks [8]

[admin] Management stuff [8]

## Tjelvar's tasks [8]

[] Other stuff [1]
[admin] Email people [1]
[admin] Attempt to fill in appriasal form [5]
[fun] Have fun [1]
"""
            self.assertEqual(text, expected, "\n" + text + expected)

        args = cli.parse_args(["list", "todo", "-p", "TO"])
        with capture_sys_output() as (stdout, stderr):
            cli.run(args)
            text = ansi_escape.sub("", stdout.getvalue())
            expected = """# TODO [8]

## Tjelvar's tasks [8]

[] Other stuff [1]
[admin] Email people [1]
[admin] Attempt to fill in appriasal form [5]
[fun] Have fun [1]
"""
            self.assertEqual(text, expected, "\n" + text + expected)

        args = cli.parse_args(["list", "done"])
        with capture_sys_output() as (stdout, stderr):
            cli.run(args)
            text = ansi_escape.sub("", stdout.getvalue())
            expected = """# DONE [0]\n"""
            self.assertEqual(text, expected, "\n" + text + expected)