File: test_init.py

package info (click to toggle)
tldr-py 0.7.0-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 236 kB
  • sloc: python: 503; makefile: 13; sh: 13
file content (50 lines) | stat: -rw-r--r-- 1,375 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import io
import os
from os import path

import yaml

from basic import BasicTestCase


class TestInit(BasicTestCase):
    def test_init(self):
        assert path.exists(self.config_path)

        expected_config = {
            'colors': {
                'command': 'cyan',
                'description': 'blue',
                'usage': 'green'
            },
            'platform': 'linux',
            'repo_directory': self.repo_dir
        }
        with io.open(self.config_path, encoding='utf-8') as f:
            config = yaml.safe_load(f)
        assert expected_config == config

    def test_wrong_platform_input(self):
        result = self.call_init_command()
        assert result.output == (
            "There is already a config file exists, skip initializing it.\n"
        )

    def test_bad_repo_location(self):
        os.remove(self.config_path)
        result = self.call_init_command(repo_dir='/notexist')
        assert result.exception.args[0] == (
            "Repo path not exist, clone it first."
        )

    def test_back_platform_input(self):
        os.remove(self.config_path)
        result = self.call_init_command(platform='myos')
        assert result.exception.args[0] == (
            "Platform should be in linux, osx or sunos."
        )