~ubuntu-branches/ubuntu/trusty/dput-ng/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/test_changes.py

  • Committer: Package Import Robot
  • Author(s): Arno Töll, Arno Töll, Luca Falavigna, Paul Tagliamonte, Bernhard R. Link, Sandro Tosi
  • Date: 2013-01-29 21:50:13 UTC
  • Revision ID: package-import@ubuntu.com-20130129215013-zk9tpfqajoflht5v
Tags: 1.4
[ Arno Töll ]
* Really fix #696659 by making sure the command line tool uses the most recent
  version of the library.
* Mark several fields to be required in profiles (incoming, method)
* Fix broken tests.
* Do not run the check-debs hook in our mentors.d.n profile
* Fix "[dcut] dm bombed out" by using the profile key only when defined
  (Closes: #698232)
* Parse the gecos field to obtain the user name / email address from the local
  system when DEBFULLNAME and DEBEMAIL are not set.
* Fix "dcut reschedule sends "None-day" to ftp-master if the delay is
  not specified" by forcing the corresponding parameter (Closes: #698719)

[ Luca Falavigna ]
* Implement default_keyid option. This is particularly useful with multiple
  GPG keys, so dcut is aware of which one to use.
* Make scp uploader aware of "port" configuration option.

[ Paul Tagliamonte ]
* Hack around Launchpad's SFTP implementation. We musn't stat *anything*.
  "Be vewy vewy quiet, I'm hunting wabbits" (Closes: #696558).
* Rewrote the test suite to actually test the majority of the codepaths we
  take during an upload. Back up to 60%.
* Added a README for the twitter hook, Thanks to Sandro Tosi for the bug,
  and Gergely Nagy for poking me about it. (Closes: #697768).
* Added a doc for helping folks install hooks into dput-ng (Closes: #697862).
* Properly remove DEFAULT from loadable config blocks. (Closes: #698157).
* Allow upload of more then one file. Thanks to Iain Lane for the
  suggestion. (Closes: #698855).

[ Bernhard R. Link ]
* allow empty incoming dir to upload directly to the home directory

[ Sandro Tosi ]
* Install example hooks (Closes: #697767).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# These files aren't really copyrightable.
2
 
 
3
 
from dput.changes import Changes
4
 
from dput.exceptions import ChangesFileException
5
 
 
6
 
chfd = 'tests/resources/changes/test.changes'
7
 
test_changes = open(chfd, 'r').read()
8
 
 
9
 
ref_obj = {
10
 
    "Format": "1.8",
11
 
    "Date": "Wed, 30 May 2012 22:17:42 -0400",
12
 
    "Source": "srcpkg",
13
 
    "Binary": "binpkg",
14
 
    "Architecture": "source",
15
 
    "Version": "1.3.2-1",
16
 
    "Distribution": "unstable",
17
 
    "Urgency": "low",
18
 
    "Maintainer": "Paul Tagliamonte <paultag@debian.org>",
19
 
    "Changed-By": "Paul Tagliamonte <paultag@ubuntu.com>"
20
 
}
21
 
 
22
 
 
23
 
def test_nonsense_fails():
24
 
    try:
25
 
        Changes(filename='fake/file',
26
 
                string='some string content')
27
 
        assert True is False
28
 
    except TypeError:
29
 
        pass
30
 
 
31
 
    try:
32
 
        Changes()
33
 
        assert True is False
34
 
    except TypeError:
35
 
        pass
36
 
 
37
 
 
38
 
def test_empty_changes():
39
 
    try:
40
 
        Changes(filename='/dev/null')
41
 
        assert True is False
42
 
    except ChangesFileException:
43
 
        pass
44
 
 
45
 
 
46
 
def test_parse_basics_string():
47
 
    ch = Changes(string=test_changes)
48
 
    assert ch.get_filename() is None
49
 
    for key in ref_obj:
50
 
        assert ch[key] == ref_obj[key]
51
 
    assert "Files" in ch
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'
56
 
 
57
 
 
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']
63
 
 
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.
69
 
 
70
 
 
71
 
def test_section_parse():
72
 
    ch = Changes(filename=chfd)
73
 
    test = {
74
 
        "non-free/python": ['non-free', 'python'],
75
 
        "contrib/foobar": ['contrib', 'foobar'],
76
 
        "python": ['main', 'python'],
77
 
    }
78
 
    for t in test:
79
 
        assert test[t] == ch._parse_section(t)
80
 
 
81
 
 
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 == ""