File: cli_tests.py

package info (click to toggle)
python-mkdocs 0.15.3-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,476 kB
  • ctags: 1,313
  • sloc: python: 3,840; makefile: 22; xml: 20
file content (70 lines) | stat: -rw-r--r-- 2,079 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
# coding: utf-8

from __future__ import unicode_literals
import unittest
import mock

from click.testing import CliRunner

from mkdocs import __main__ as cli


class CLITests(unittest.TestCase):

    def setUp(self):
        self.runner = CliRunner()

    @mock.patch('mkdocs.commands.serve.serve', autospec=True)
    def test_serve(self, mock_serve):

        result = self.runner.invoke(
            cli.cli, ["serve", ], catch_exceptions=False)

        self.assertEqual(result.exit_code, 0)
        self.assertEqual(mock_serve.call_count, 1)

    @mock.patch('mkdocs.commands.build.build', autospec=True)
    def test_build(self, mock_build):

        result = self.runner.invoke(
            cli.cli, ["build", ], catch_exceptions=False)

        self.assertEqual(result.exit_code, 0)
        self.assertEqual(mock_build.call_count, 1)

    @mock.patch('mkdocs.commands.build.build', autospec=True)
    def test_build_verbose(self, mock_build):

        result = self.runner.invoke(
            cli.cli, ["--verbose", "build"], catch_exceptions=False)

        self.assertEqual(result.exit_code, 0)
        self.assertEqual(mock_build.call_count, 1)

    @mock.patch('mkdocs.commands.build.build', autospec=True)
    def test_json(self, mock_build):

        result = self.runner.invoke(
            cli.cli, ["json", ], catch_exceptions=False)

        self.assertEqual(result.exit_code, 0)
        self.assertEqual(mock_build.call_count, 1)

    @mock.patch('mkdocs.commands.new.new', autospec=True)
    def test_new(self, mock_new):

        result = self.runner.invoke(
            cli.cli, ["new", "project"], catch_exceptions=False)

        self.assertEqual(result.exit_code, 0)
        self.assertEqual(mock_new.call_count, 1)

    @mock.patch('mkdocs.commands.gh_deploy.gh_deploy', autospec=True)
    def test_gh_deploy(self, mock_gh_deploy):

        result = self.runner.invoke(
            cli.cli, ["gh-deploy"], catch_exceptions=False)

        self.assertEqual(result.exit_code, 0)
        self.assertEqual(mock_gh_deploy.call_count, 1)