1
# These files aren't really copyrightable.
3
from dput.changes import Changes
4
from dput.exceptions import ChangesFileException
6
chfd = 'tests/resources/changes/test.changes'
7
test_changes = open(chfd, 'r').read()
11
"Date": "Wed, 30 May 2012 22:17:42 -0400",
14
"Architecture": "source",
16
"Distribution": "unstable",
18
"Maintainer": "Paul Tagliamonte <paultag@debian.org>",
19
"Changed-By": "Paul Tagliamonte <paultag@ubuntu.com>"
23
def test_nonsense_fails():
25
Changes(filename='fake/file',
26
string='some string content')
38
def test_empty_changes():
40
Changes(filename='/dev/null')
42
except ChangesFileException:
46
def test_parse_basics_string():
47
ch = Changes(string=test_changes)
48
assert ch.get_filename() is None
50
assert ch[key] == ref_obj[key]
52
assert not "KruftyTag" in ch
53
assert "srcpkg" == ch.get("source", None)
54
assert ch.get('kruftykrufty', None) is None
55
assert ch.get_pool_path() == 'pool/main/s/srcpkg'
58
def test_parse_basics_file():
59
ch = Changes(filename=chfd)
60
assert ch.get_filename() == 'test.changes'
61
assert ch.get_changes_file() == 'test.changes'
62
assert ch.get_files() == ['fileone', 'filetwo', 'filethree', 'foo.dsc']
64
assert ch.get_component() == 'main'
65
assert ch.get_priority() == 'priority'
66
assert ch.get_dsc() == 'foo.dsc'
67
assert ch.get_diff() is None
68
# XXX: test the positive condition.
71
def test_section_parse():
72
ch = Changes(filename=chfd)
74
"non-free/python": ['non-free', 'python'],
75
"contrib/foobar": ['contrib', 'foobar'],
76
"python": ['main', 'python'],
79
assert test[t] == ch._parse_section(t)
82
def test_directory_stuff():
83
ch = Changes(filename=chfd)
84
assert ch._directory == ""
85
ch.set_directory('foobar')
86
assert ch._directory == "foobar"
87
ch.set_directory(None)
88
assert ch._directory == ""