diff mbox

[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 594: Added couple of tests for mmc_id field handling.

Message ID 20121227104313.7292.46055.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Fathi Boudra Dec. 27, 2012, 10:43 a.m. UTC
Merge authors:
  Milo Casagrande (milo)
Related merge proposals:
  https://code.launchpad.net/~milo/linaro-image-tools/bug1085412/+merge/141324
  proposed by: Milo Casagrande (milo)
  review: Approve - Fathi Boudra (fboudra)
------------------------------------------------------------
revno: 594 [merge]
committer: Fathi Boudra <fathi.boudra@linaro.org>
branch nick: linaro-image-tools
timestamp: Thu 2012-12-27 12:41:25 +0200
message:
  Added couple of tests for mmc_id field handling.
modified:
  linaro_image_tools/hwpack/tests/test_config_v3.py
  linaro_image_tools/hwpack/tests/test_hwpack_converter.py


--
lp:linaro-image-tools
https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk

You are subscribed to branch lp:linaro-image-tools.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'linaro_image_tools/hwpack/tests/test_config_v3.py'
--- linaro_image_tools/hwpack/tests/test_config_v3.py	2012-12-07 08:47:58 +0000
+++ linaro_image_tools/hwpack/tests/test_config_v3.py	2012-12-27 10:29:42 +0000
@@ -347,6 +347,13 @@ 
         self.assertValidationError("Invalid serial tty: ttxSAC1",
                                    config._validate_serial_tty)
 
+    def test_validate_mmc_id_wrong(self):
+        # The mmc_id value, if coming from a yaml file, has to be quoted.
+        # Make sure the test does not accept a valid-unquoted value.
+        config = self.get_config(self.valid_complete_v3 +
+                                 "mmc_id: 1:1\n")
+        self.assertRaises(HwpackConfigError, config._validate_mmc_id)
+
     def test_validate_mmc_id(self):
         config = self.get_config(self.valid_complete_v3 +
                                  "mmc_id: x\n")

=== modified file 'linaro_image_tools/hwpack/tests/test_hwpack_converter.py'
--- linaro_image_tools/hwpack/tests/test_hwpack_converter.py	2012-10-17 14:53:24 +0000
+++ linaro_image_tools/hwpack/tests/test_hwpack_converter.py	2012-12-27 10:29:42 +0000
@@ -166,3 +166,18 @@ 
         converter = HwpackConverter(input_file, output_file)
         converter._parse()
         self.assertEqual(out_format, str(converter))
+
+    def test_mmc_id(self):
+        """Test correct handling of mmc_id field.
+
+        The mmc_id field has to be quoted coming out from the converter
+        otherwise when reading the yaml file the value is read as a number,
+        not a string."""
+        ini_format = ("[hwpack]\nformat=2.0\nmmc_id=1:1")
+        out_format = ("format: '3.0'\nmmc_id: '1:1'\n")
+        input_file = self.useFixture(CreateTempFileFixture(ini_format)).\
+                                                                get_file_name()
+        output_file = self.useFixture(CreateTempFileFixture()).get_file_name()
+        converter = HwpackConverter(input_file, output_file)
+        converter._parse()
+        self.assertEqual(out_format, str(converter))