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

« back to all changes in this revision

Viewing changes to src/provisioningserver/boot/tests/test_install_bootloader.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:
22
22
    age_file,
23
23
    get_write_time,
24
24
    )
25
 
import provisioningserver.boot.install_bootloader
26
25
from provisioningserver.boot.install_bootloader import (
27
26
    install_bootloader,
28
27
    make_destination,
29
28
    )
30
 
from provisioningserver.boot.tftppath import locate_tftp_path
31
 
from provisioningserver.testing.config import set_tftp_root
32
 
from provisioningserver.utils import MainScript
33
29
from testtools.matchers import (
34
30
    DirExists,
35
31
    FileContains,
36
 
    FileExists,
37
32
    )
38
33
 
39
34
 
40
35
class TestInstallBootloader(MAASTestCase):
41
36
 
42
37
    def test_integration(self):
43
 
        tftproot = self.make_dir()
44
 
        config_fixture = self.useFixture(set_tftp_root(tftproot))
45
 
 
46
 
        loader = self.make_file()
47
 
 
48
 
        action = factory.make_name("action")
49
 
        script = MainScript(action)
50
 
        script.register(action, provisioningserver.boot.install_bootloader)
51
 
        script.execute(
52
 
            ("--config-file", config_fixture.filename, action,
53
 
             "--loader", loader))
54
 
 
55
 
        bootloader_filename = os.path.basename(loader)
56
 
        self.assertThat(
57
 
            locate_tftp_path(
58
 
                bootloader_filename, tftproot=tftproot),
59
 
            FileExists())
 
38
        loader_contents = factory.getRandomString()
 
39
        loader = self.make_file(contents=loader_contents)
 
40
        destination = self.make_file()
 
41
        install_bootloader(loader, destination)
 
42
        self.assertThat(destination, FileContains(loader_contents))
60
43
 
61
44
    def test_make_destination_creates_directory_if_not_present(self):
62
45
        tftproot = self.make_dir()