~smoser/ubuntu/trusty/maas/lp-1172566

« back to all changes in this revision

Viewing changes to src/provisioningserver/boot/tests/test_tftppath.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2014-04-03 13:45:02 UTC
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: package-import@ubuntu.com-20140403134502-8a6wvuqwyuekufh0
Tags: upstream-1.5+bzr2227
ImportĀ upstreamĀ versionĀ 1.5+bzr2227

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
__metaclass__ = type
15
15
__all__ = []
16
16
 
 
17
import errno
17
18
import os.path
18
19
 
19
20
from maastesting.factory import factory
20
21
from maastesting.testcase import MAASTestCase
 
22
from mock import Mock
 
23
from provisioningserver.boot import tftppath
21
24
from provisioningserver.boot.tftppath import (
22
25
    compose_image_path,
23
26
    drill_down,
35
38
    Not,
36
39
    StartsWith,
37
40
    )
 
41
from testtools.testcase import ExpectedException
38
42
 
39
43
 
40
44
def make_image(params, purpose):
95
99
        self.assertEqual(
96
100
            self.tftproot, locate_tftp_path(None, tftproot=self.tftproot))
97
101
 
 
102
    def test_list_boot_images_copes_with_missing_directory(self):
 
103
        self.assertEqual([], list_boot_images(factory.getRandomString()))
 
104
 
 
105
    def test_list_boot_images_passes_on_other_exceptions(self):
 
106
        error = OSError(errno.EACCES, "Deliberate error for testing.")
 
107
        self.patch(tftppath, 'list_subdirs', Mock(side_effect=error))
 
108
        with ExpectedException(OSError):
 
109
            list_boot_images(factory.getRandomString())
 
110
 
98
111
    def test_list_boot_images_copes_with_empty_directory(self):
99
112
        self.assertEqual([], list_boot_images(self.tftproot))
100
113