Merge lp:~sergiusens/snapcraft/1501494 into lp:~snappy-dev/snapcraft/core

Proposed by Sergio Schvezov
Status: Merged
Approved by: Michael Vogt
Approved revision: 224
Merged at revision: 224
Proposed branch: lp:~sergiusens/snapcraft/1501494
Merge into: lp:~snappy-dev/snapcraft/core
Diff against target: 46 lines (+26/-0)
2 files modified
snapcraft/tests/test_yaml.py (+22/-0)
snapcraft/yaml.py (+4/-0)
To merge this branch: bzr merge lp:~sergiusens/snapcraft/1501494
Reviewer Review Type Date Requested Status
Michael Vogt (community) Approve
Review via email: mp+272982@code.launchpad.net

Commit message

Backwards compatibility for using type

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snapcraft/tests/test_yaml.py'
2--- snapcraft/tests/test_yaml.py 2015-09-29 13:36:43 +0000
3+++ snapcraft/tests/test_yaml.py 2015-09-30 20:42:09 +0000
4@@ -198,6 +198,28 @@
5 self.assertEqual(raised.exception.message, '\'myapp@me_1.0\' does not match \'^[a-z0-9][a-z0-9+-]*$\'')
6
7 @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')
8+ def test_deprecation_for_type(self, mock_loadPlugin):
9+ fake_logger = fixtures.FakeLogger(level=logging.WARNING)
10+ self.useFixture(fake_logger)
11+
12+ self.make_snapcraft_yaml("""name: myapp
13+version: "1"
14+vendor: me <me@me.com>
15+summary: test
16+description: nothing
17+icon: my-icon.png
18+
19+parts:
20+ part1:
21+ type: go
22+ stage-packages: [fswebcam]
23+""")
24+ config = snapcraft.yaml.Config()
25+ self.assertEqual(fake_logger.output,
26+ 'DEPRECATED: Use "plugin" instead of "type"\n')
27+ self.assertFalse('type' in config.data)
28+
29+ @unittest.mock.patch('snapcraft.yaml.Config.load_plugin')
30 def test_invalid_yaml_missing_description(self, mock_loadPlugin):
31 fake_logger = fixtures.FakeLogger(level=logging.ERROR)
32 self.useFixture(fake_logger)
33
34=== modified file 'snapcraft/yaml.py'
35--- snapcraft/yaml.py 2015-09-30 19:44:28 +0000
36+++ snapcraft/yaml.py 2015-09-30 20:42:09 +0000
37@@ -86,6 +86,10 @@
38
39 plugin_name = properties.pop("plugin", None)
40 # TODO search the wiki
41+ if not plugin_name and 'type' in properties:
42+ plugin_name = properties.pop('type')
43+ logger.warning('DEPRECATED: Use "plugin" instead of "type"')
44+
45 if not plugin_name:
46 raise PluginNotDefinedError
47

Subscribers

People subscribed via source and target branches