Ejemplo n.º 1
0
    def test_xo_create(self):
        game_name = self._game_name()

        with clean_home_directory():
            with std_output() as (out, err):
                xo_cli.main(prog_name='xo', args=['init'])
                xo_cli.main(prog_name='xo',
                            args=['create', game_name, '--wait'])

            self.assertEquals(err.getvalue(), '')

            with std_output() as (out, err):
                xo_cli.main(prog_name='xo', args=['list'])

            self.assertEquals(err.getvalue(), '')

            game_found = False
            for line in out.getvalue().split('\n'):
                if line.startswith("{} ".format(game_name)):
                    print line
                    game_found = True
            self.assertTrue(game_found)
Ejemplo n.º 2
0
    def test_xo_create(self):
        game_name = self._game_name()

        with clean_home_directory():
            with std_output() as (out, err):
                    xo_cli.main(prog_name='xo', args=['init'])
                    xo_cli.main(prog_name='xo',
                                args=['create', game_name, '--wait'])

            self.assertEquals(err.getvalue(), '')

            with std_output() as (out, err):
                xo_cli.main(prog_name='xo', args=['list'])

            self.assertEquals(err.getvalue(), '')

            game_found = False
            for line in out.getvalue().split('\n'):
                if line.startswith("{} ".format(game_name)):
                    print line
                    game_found = True
            self.assertTrue(game_found)
Ejemplo n.º 3
0
    def test_xo_p1_win(self):
        game_name = self._game_name()

        with clean_home_directory():
            with std_output() as (out, err):
                xo_cli.main(prog_name='xo',
                            args=['init', '--username=player1'])
                xo_cli.main(prog_name='xo',
                            args=['create', game_name, '--wait'])
                xo_cli.main(prog_name='xo', args=['take', game_name, '3'])
                xo_cli.main(prog_name='xo',
                            args=['init', '--username=player2'])
                xo_cli.main(prog_name='xo', args=['take', game_name, '1'])
                xo_cli.main(prog_name='xo',
                            args=['init', '--username=player1'])
                xo_cli.main(prog_name='xo', args=['take', game_name, '5'])
                xo_cli.main(prog_name='xo',
                            args=['init', '--username=player2'])
                xo_cli.main(prog_name='xo', args=['take', game_name, '2'])
                xo_cli.main(prog_name='xo',
                            args=['init', '--username=player1'])
                xo_cli.main(prog_name='xo',
                            args=['take', game_name, '7', '--wait'])

            self.assertEquals(err.getvalue(), '')

            with std_output() as (out, err):
                xo_cli.main(prog_name='xo', args=['show', game_name])

            self.assertIn('P1-WIN', out.getvalue())
Ejemplo n.º 4
0
    def test_xo_p1_win(self):
        game_name = self._game_name()

        with clean_home_directory():
            with std_output() as (out, err):
                xo_cli.main(prog_name='xo',
                            args=['init', '--username=player1'])
                xo_cli.main(prog_name='xo',
                            args=['create', game_name, '--wait'])
                xo_cli.main(prog_name='xo',
                            args=['take', game_name, '3'])
                xo_cli.main(prog_name='xo',
                            args=['init', '--username=player2'])
                xo_cli.main(prog_name='xo',
                            args=['take', game_name, '1'])
                xo_cli.main(prog_name='xo',
                            args=['init', '--username=player1'])
                xo_cli.main(prog_name='xo',
                            args=['take', game_name, '5'])
                xo_cli.main(prog_name='xo',
                            args=['init', '--username=player2'])
                xo_cli.main(prog_name='xo',
                            args=['take', game_name, '2'])
                xo_cli.main(prog_name='xo',
                            args=['init', '--username=player1'])
                xo_cli.main(prog_name='xo',
                            args=['take', game_name, '7', '--wait'])

            self.assertEquals(err.getvalue(), '')

            with std_output() as (out, err):
                xo_cli.main(prog_name='xo', args=['show', game_name])

            self.assertIn('P1-WIN', out.getvalue())