Merge lp:~jamesodhunt/ubuntu/vivid/ubuntu-core-upgrader/implement-format-command into lp:ubuntu/vivid/ubuntu-core-upgrader
Proposed by
James Hunt
Status: | Merged |
---|---|
Merged at revision: | 23 |
Proposed branch: | lp:~jamesodhunt/ubuntu/vivid/ubuntu-core-upgrader/implement-format-command |
Merge into: | lp:ubuntu/vivid/ubuntu-core-upgrader |
Diff against target: |
215 lines (+131/-7) 3 files modified
debian/changelog (+7/-0) ubuntucoreupgrader/tests/test_upgrader.py (+45/-0) ubuntucoreupgrader/upgrader.py (+79/-7) |
To merge this branch: | bzr merge lp:~jamesodhunt/ubuntu/vivid/ubuntu-core-upgrader/implement-format-command |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu branches | Pending | ||
Review via email: mp+255359@code.launchpad.net |
Description of the change
* Implement s-i format command to handle full-image (non-delta) updates
correctly.
Details:
* ubuntucoreupgra
- test_format(): New test to ensure mkfs called appropriately.
* ubuntucoreupgra
- get_mount_
To post a comment you must log in.
Thanks for working on this! I like the tests!
I put some comments inline.
A note about the tests that is too big to fit into the inline comments. The tests can be simplified by using the automatic mocking features from unittest.mock. It provides automatic construction of mock function and asserts to test if the mocks go called (or got called with the right parameters). So something like: ader/tests/ test_upgrader. py' der/tests/ test_upgrader. py 2015-04-07 13:30:32 +0000 der/tests/ test_upgrader. py 2015-04-08 14:18:03 +0000
"""
=== modified file 'ubuntucoreupgr
--- ubuntucoreupgra
+++ ubuntucoreupgra
@@ -195,18 +195,6 @@
return l
-def mock_get_ mount_details( target) : target, options=None): derObectTestCas e(UbuntuCoreUpg raderTestCase) :
- return [True, True, True]
-
-
-def mock_mount(source, target, options=None):
- pass
-
-
-def mock_unmount(
- pass
-
-
class UbuntuCoreUpgra
def mock_get_ cache_dir( self):
@@ -255,20 +243,16 @@
- @patch( 'ubuntucoreupgr ader.upgrader. get_mount_ details' , mount_details) 'ubuntucoreupgr ader.upgrader. mount', mock_mount) 'ubuntucoreupgr ader.upgrader. unmount' , mock_unmount) 'ubuntucoreupgr ader.upgrader. get_mount_ details' ) 'ubuntucoreupgr ader.upgrader. mount') 'ubuntucoreupgr ader.upgrader. unmount' ) details) : details. return_ value = MOCK_FS_TUPLE ubuntucoreupgra der.upgrader. mkfs', mock_mkfs): ubuntucoreupgra der.upgrader. mkfs') as mock_mkfs:
options = parse_args( args=args)
commands = make_commands( [self.TARFILE] )
- mock_get_
- @patch(
- @patch(
- def test_format(self):
-
- self.mkfs_called = False
-
- def mock_mkfs(device, fs_type, label):
- self.mkfs_called = True
-
+ @patch(
+ @patch(
+ @patch(
+ def test_format(self, mock_umount, mock_mount, mock_mount_
+ MOCK_FS_TUPLE = ("device", "fstype", "label")
+ mock_mount_
+
# If the command file does not contain the format command, mkfs
# should not be called.
- with patch('
+ with patch('
args = ['cmdfile']
@@ -279,11 +263,11 @@
# No format command in command file, so should not have been e(self. mkfs_called) e(mock_ mkfs.called)
# called.
- self.assertFals
+ self.assertFals
# mkfs should be called if the format command is specified in ubuntucoreupgra der.upgrader. mkfs', mock_mkfs): ubuntucoreupgra der.upgrader. mkfs') as mock_mkfs:
options = parse_args( args=args)
commands = make_commands( [self.TARFILE] )
upgrader. MOUNTPOINT_ CMD = "true"
upgrader. run()
# the command file.
- with patch('
+ with patch('
args = ['cmdfile']
@@ -296,8 +280,7 @@
- self.assertTrue (self.mkfs_ called) assert_ called_ with(*MOCK_ FS_TUPLE)
-
+ mock_mkfs.
if __name__ == "__main__": main()
unittest.
"""