File: go2setup.test

package info (click to toggle)
go2 1.20121210-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 224 kB
  • ctags: 296
  • sloc: python: 1,222; makefile: 34; sh: 9
file content (50 lines) | stat: -rwxr-xr-x 1,158 bytes parent folder | download | duplicates (2)
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/atheist
# -*- mode:python; coding:utf-8 -*-

import sys
import os

import unittest2 as unittest
import fs
from fs.memoryfs import MemoryFS
from pyDoubles.framework import *

sys.path.append('$basedir')

import go2


def create_basic_dirs(fs):
    home = go2.USERDIR
    fs.makedir(home, recursive=True)


BASHRC = os.path.join(go2.USERDIR, '.bashrc')

class Test_setup(unittest.TestCase):
    def setUp(self):
        self.fs = MemoryFS()
        create_basic_dirs(self.fs)

        config = go2.get_config([])
        config.fs = self.fs
        go2.config = config
        go2.ResourceNotFoundError = fs.ResourceNotFoundError

        os.chdir(go2.USERDIR)

    def test_bashrc_missing(self):
        go2.go2setup()
        self.assert_(go2.ACTIVATION_CMD in self.fs.getcontents(BASHRC))

    def test_bashrc_exists(self):
        self.fs.setcontents(BASHRC, "something")
        self.assertEquals(go2.go2setup(), None)
        self.assert_(go2.ACTIVATION_CMD in self.fs.getcontents(BASHRC))

    def test_already_setup(self):
        self.fs.setcontents(BASHRC, go2.ACTIVATION_CMD)
        self.assertEquals(go2.go2setup(), 1)


UnitTestCase()