~intellectronica/launchpad/max-heat-from-context

« back to all changes in this revision

Viewing changes to lib/lp/buildmaster/tests/test_buildbase.py

  • Committer: Tom Berger
  • Date: 2010-03-08 13:43:47 UTC
  • mfrom: (7675.2879.30 launchpad)
  • Revision ID: tom.berger@canonical.com-20100308134347-216mjmwefq0yyham
merge changes from devel

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright 2010 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
 
4
from __future__ import with_statement
 
5
 
4
6
"""Tests for `IBuildBase`."""
5
7
 
6
8
__metaclass__ = type
45
47
 
46
48
    layer = DatabaseFunctionalLayer
47
49
 
 
50
    def test_getUploadLogContent_nolog(self):
 
51
        """If there is no log file there, a string explaining that is returned.
 
52
        """
 
53
        self.useTempDir()
 
54
        build_base = BuildBase()
 
55
        self.assertEquals('Could not find upload log file', 
 
56
            build_base.getUploadLogContent(os.getcwd(), "myleaf"))
 
57
 
 
58
    def test_getUploadLogContent_only_dir(self):
 
59
        """If there is a directory but no log file, expect the error string,
 
60
        not an exception."""
 
61
        self.useTempDir()
 
62
        os.makedirs("accepted/myleaf")
 
63
        build_base = BuildBase()
 
64
        self.assertEquals('Could not find upload log file', 
 
65
            build_base.getUploadLogContent(os.getcwd(), "myleaf"))
 
66
 
 
67
    def test_getUploadLogContent_readsfile(self):
 
68
        """If there is a log file, return its contents."""
 
69
        self.useTempDir()
 
70
        os.makedirs("accepted/myleaf")
 
71
        with open('accepted/myleaf/uploader.log', 'w') as f:
 
72
            f.write('foo')
 
73
        build_base = BuildBase()
 
74
        self.assertEquals('foo',
 
75
            build_base.getUploadLogContent(os.getcwd(), "myleaf"))
 
76
 
48
77
    def test_getUploaderCommand(self):
49
78
        build_base = BuildBase()
50
79
        upload_leaf = self.factory.getUniqueString('upload-leaf')