summaryrefslogtreecommitdiffstats
path: root/tests/test_gd_diff.py
blob: 650094f06f3cdfd11f057477e584b720aa15809f (plain) (blame)
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
#  This file is part of gns-deb-diff.
#
#  gns-deb-diff is under the Public Domain. See
#  <https://creativecommons.org/publicdomain/zero/1.0>

import os
import sys

from nose.tools import *

from gd_diff import *

class TestGdDiff(object):

    def setup(self):
        """Setup method for this class."""
        self.pkgs_file = "tests/files/pkgs.list"
        self.pkgs_file_ne = 'tests/nonexistent-file.list'

    def test_read_file_success(self):
        f_content = read_file(self.pkgs_file)

        assert isinstance(f_content, str)
        assert_equal(len(f_content.split('\n')), 82)

    @raises(SystemExit)
    def test_read_file_error(self):
        with open(os.devnull, 'w') as sys.stderr:
            f_content = read_file(self.pkgs_file_ne)


    def test_get_packages(self):
        pkgs_iter = get_packages(self.pkgs_file)
        assert len(list(pkgs_iter)) == 82

    def test_get_packages_sanity(self):
        pkgs_iter = get_packages(self.pkgs_file)

        for pkg in pkgs_iter:
            assert not ' ' in pkg

    def teardown(self):
        """Teardown method for this class."""
        pass