~curtin-dev/curtin/bionic

« back to all changes in this revision

Viewing changes to tests/unittests/test_block_mdadm.py

  • Committer: Scott Moser
  • Date: 2017-08-03 19:51:16 UTC
  • mfrom: (1.1.50)
  • Revision ID: smoser@ubuntu.com-20170803195116-0xc6onji18peerm5
* New upstream snapshot.
  - tests: Add CiTestCase common parent for all curtin tests.
  - vmtests: Remove force flag for centos curthooks
  - tools/jenkins-runner: improve tgtd cleanup logic
  - tests: Drop EOL Wily Vivid and Yakkety tests.
  - Disable yum plugins when installing packages, update ca-certs for https
  - Rename centos_network_curthooks -> centos_apply_network_config.
  - tests: in centos_defaults use write_files for grub serial.
  - write_files: write files after extract, change write_files signature.
  - pass network configuration through to target for ubuntu and centos
  - tests: disable yakkety tests.
  - tools/launch: automatically pass on proxy settings to curtin
  - Add top level 'proxy' to config, deprecate top level http_proxy.
  - tools/curtainer: fix to enable deb-src for -proposed.
  - Use unshare to put chroot commands in own pid namespace.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from unittest import TestCase
2
1
from mock import call, patch
3
2
from curtin.block import dev_short
4
3
from curtin.block import mdadm
5
4
from curtin import util
 
5
from .helpers import CiTestCase
6
6
import os
7
7
import subprocess
8
8
import textwrap
9
9
 
10
10
 
11
 
class MdadmTestBase(TestCase):
12
 
    def setUp(self):
13
 
        super(MdadmTestBase, self).setUp()
14
 
 
15
 
    def add_patch(self, target, attr):
16
 
        """Patches specified target object and sets it as attr on test
17
 
        instance also schedules cleanup"""
18
 
        m = patch(target, autospec=True)
19
 
        p = m.start()
20
 
        self.addCleanup(m.stop)
21
 
        setattr(self, attr, p)
22
 
 
23
 
 
24
 
class TestBlockMdadmAssemble(MdadmTestBase):
 
11
class TestBlockMdadmAssemble(CiTestCase):
 
12
 
25
13
    def setUp(self):
26
14
        super(TestBlockMdadmAssemble, self).setUp()
27
15
        self.add_patch('curtin.block.mdadm.util', 'mock_util')
94
82
            rcs=[0, 1, 2])
95
83
 
96
84
 
97
 
class TestBlockMdadmCreate(MdadmTestBase):
 
85
class TestBlockMdadmCreate(CiTestCase):
98
86
    def setUp(self):
99
87
        super(TestBlockMdadmCreate, self).setUp()
100
88
        self.add_patch('curtin.block.mdadm.util', 'mock_util')
243
231
        self.mock_util.subp.assert_has_calls(expected_calls)
244
232
 
245
233
 
246
 
class TestBlockMdadmExamine(MdadmTestBase):
 
234
class TestBlockMdadmExamine(CiTestCase):
247
235
    def setUp(self):
248
236
        super(TestBlockMdadmExamine, self).setUp()
249
237
        self.add_patch('curtin.block.mdadm.util', 'mock_util')
328
316
        self.assertEqual(data, {})
329
317
 
330
318
 
331
 
class TestBlockMdadmStop(MdadmTestBase):
 
319
class TestBlockMdadmStop(CiTestCase):
332
320
    def setUp(self):
333
321
        super(TestBlockMdadmStop, self).setUp()
334
322
        self.add_patch('curtin.block.mdadm.util.lsb_release', 'mock_util_lsb')
495
483
        self.mock_util_write_file.assert_has_calls(expected_writes)
496
484
 
497
485
 
498
 
class TestBlockMdadmRemove(MdadmTestBase):
 
486
class TestBlockMdadmRemove(CiTestCase):
499
487
    def setUp(self):
500
488
        super(TestBlockMdadmRemove, self).setUp()
501
489
        self.add_patch('curtin.block.mdadm.util', 'mock_util')
521
509
        self.mock_util.subp.assert_has_calls(expected_calls)
522
510
 
523
511
 
524
 
class TestBlockMdadmQueryDetail(MdadmTestBase):
 
512
class TestBlockMdadmQueryDetail(CiTestCase):
525
513
    def setUp(self):
526
514
        super(TestBlockMdadmQueryDetail, self).setUp()
527
515
        self.add_patch('curtin.block.mdadm.util', 'mock_util')
599
587
                         '93a73e10:427f280b:b7076c02:204b8f7a')
600
588
 
601
589
 
602
 
class TestBlockMdadmDetailScan(MdadmTestBase):
 
590
class TestBlockMdadmDetailScan(CiTestCase):
603
591
    def setUp(self):
604
592
        super(TestBlockMdadmDetailScan, self).setUp()
605
593
        self.add_patch('curtin.block.mdadm.util', 'mock_util')
634
622
        self.assertEqual(None, data)
635
623
 
636
624
 
637
 
class TestBlockMdadmMdHelpers(MdadmTestBase):
 
625
class TestBlockMdadmMdHelpers(CiTestCase):
638
626
    def setUp(self):
639
627
        super(TestBlockMdadmMdHelpers, self).setUp()
640
628
        self.add_patch('curtin.block.mdadm.util', 'mock_util')