Exemple #1
0
 def test_rm_usage(self):
     from jicagile.cli import CLI
     cli = CLI()
     args = cli.parse_args(["teammember", "rm", "TO"])
     self.assertEqual(args.command, "teammember")
     self.assertEqual(args.subcommand, "rm")
     self.assertEqual(args.lookup, "TO")
Exemple #2
0
 def test_rm_usage(self):
     from jicagile.cli import CLI
     cli = CLI()
     args = cli.parse_args(["theme", "rm", "admin"])
     self.assertEqual(args.command, "theme")
     self.assertEqual(args.subcommand, "rm")
     self.assertEqual(args.name, "admin")
Exemple #3
0
 def test_mv_usage(self):
     from jicagile.cli import CLI
     cli = CLI()
     args = cli.parse_args(["mv", "path/to/move", "/dest/"])
     self.assertEqual(args.command, "mv")
     self.assertEqual(args.src, "path/to/move")
     self.assertEqual(args.dest, "/dest/")
Exemple #4
0
 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)
Exemple #5
0
 def test_basic_usage(self):
     from jicagile.cli import CLI
     cli = CLI()
     args = cli.parse_args(["add", "Simple task", "1"])
     self.assertEqual(args.command, "add")
     self.assertEqual(args.title, "Simple task")
     self.assertEqual(args.storypoints, 1)
     self.assertFalse(args.current)
Exemple #6
0
 def test_add_usage(self):
     from jicagile.cli import CLI
     cli = CLI()
     args = cli.parse_args(["theme", "add", "admin", "report writing"])
     self.assertEqual(args.command, "theme")
     self.assertEqual(args.subcommand, "add")
     self.assertEqual(args.name, "admin")
     self.assertEqual(args.description, "report writing")
Exemple #7
0
 def test_add_usage(self):
     from jicagile.cli import CLI
     cli = CLI()
     args = cli.parse_args(["teammember", "add", "TO", "Tjelvar", "Olsson"])
     self.assertEqual(args.command, "teammember")
     self.assertEqual(args.subcommand, "add")
     self.assertEqual(args.lookup, "TO")
     self.assertEqual(args.first_name, "Tjelvar")
     self.assertEqual(args.last_name, "Olsson")
Exemple #8
0
 def test_primary_contact(self):
     from jicagile import Team
     from jicagile.cli import CLI
     team = Team()
     team.add_member("TO", "Tjelvar", "Olsson")
     cli = CLI()
     cli.project.team = team
     args = cli.parse_args(["list", "dirpath", "-p", "TO"])
     self.assertEqual(args.primary_contact, "TO")
Exemple #9
0
    def test_themes(self):
        import jicagile.config
        from jicagile.cli import CLI
        cli = CLI()

        themes = jicagile.config.Themes()
        themes.add_member("sysadmin", "managing linux desktops and servers")
        cli.project.themes = themes

        args = cli.parse_args(["add", "Simple task", "1", "-e", "sysadmin"])
        self.assertEqual(args.theme, "sysadmin")
Exemple #10
0
    def test_primary_contact(self):
        import jicagile
        from jicagile.cli import CLI
        cli = CLI()

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

        args = cli.parse_args(["add", "Simple task", "1", "-p", "TO"])
        self.assertEqual(args.primary_contact, "TO")
Exemple #11
0
    def test_valid_storypoint_choices(self):
        from jicagile.cli import CLI
        cli = CLI()

        for s in [1, 3, 5, 8]:
            args = cli.parse_args(["add", "Simple task", str(s)])
            self.assertEqual(args.storypoints, s)

        for s in [2, 4, 6, 7, 9]:
            with self.assertRaises(SystemExit):
                with capture_sys_output() as (stdout, stderr):
                    args = cli.parse_args(["add", "Simple task", str(s)])
Exemple #12
0
    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)
Exemple #13
0
    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)
Exemple #14
0
    def test_basic_usage(self):
        import jicagile
        from jicagile.cli import CLI
        cli = CLI()

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

        args = cli.parse_args(["edit", "fpath",
                               "-t", "Simple task",
                               "-s", "1",
                               "-p", "TO"])
        self.assertEqual(args.command, "edit")
        self.assertEqual(args.fpath, "fpath")
        self.assertEqual(args.title, "Simple task")
        self.assertEqual(args.storypoints, 1)
        self.assertEqual(args.primary_contact, "TO")
Exemple #15
0
    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")
Exemple #16
0
    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))
Exemple #17
0
    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)
Exemple #18
0
 def test_current(self):
     from jicagile.cli import CLI
     cli = CLI()
     args = cli.parse_args(["add", "-c", "Simple task", "1"])
     self.assertTrue(args.current)
Exemple #19
0
    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)
Exemple #20
0
    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)
Exemple #21
0
    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)
Exemple #22
0
 def test_basic_usage(self):
     from jicagile.cli import CLI
     cli = CLI()
     args = cli.parse_args(["list", "dirpath"])
     self.assertEqual(args.command, "list")
     self.assertEqual(args.directory, "dirpath")