Merge lp:~mvo/snapcraft/demo-plugin-test into lp:~xubuntu-dev/snapcraft/demo

Proposed by Michael Vogt
Status: Merged
Merge reported by: Michael Terry
Merged at revision: not available
Proposed branch: lp:~mvo/snapcraft/demo-plugin-test
Merge into: lp:~xubuntu-dev/snapcraft/demo
Prerequisite: lp:~mvo/snapcraft/demo-pep8-pyflakes
Diff against target: 43 lines (+27/-0)
2 files modified
run-checks.sh (+2/-0)
snapcraft/tests/test_plugins.py (+25/-0)
To merge this branch: bzr merge lp:~mvo/snapcraft/demo-plugin-test
Reviewer Review Type Date Requested Status
Michael Terry Approve
Review via email: mp+263368@code.launchpad.net

Description of the change

Add an initial test for the plugins

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

I rebased this on trunk and committed. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'run-checks.sh'
2--- run-checks.sh 2015-06-30 14:52:41 +0000
3+++ run-checks.sh 2015-06-30 14:52:41 +0000
4@@ -13,5 +13,7 @@
5 exit 1
6 fi
7
8+python3 -m unittest
9+
10 pyflakes3 $PY
11 pep8 $PY
12
13=== added directory 'snapcraft/tests'
14=== added file 'snapcraft/tests/__init__.py'
15=== added file 'snapcraft/tests/test_plugins.py'
16--- snapcraft/tests/test_plugins.py 1970-01-01 00:00:00 +0000
17+++ snapcraft/tests/test_plugins.py 2015-06-30 14:52:41 +0000
18@@ -0,0 +1,25 @@
19+#!/usr/bin/python
20+
21+import os
22+import tempfile
23+import unittest
24+from unittest.mock import Mock
25+
26+from snapcraft.plugin import Plugin
27+
28+
29+class TestPlugin(unittest.TestCase):
30+
31+ def test_is_dirty(self):
32+ p = Plugin("", "mock", "mock-part", {})
33+ p.statefile = tempfile.NamedTemporaryFile().name
34+ self.addCleanup(os.remove, p.statefile)
35+ p.partNames = ["mock-part"]
36+ p.code = Mock()
37+ # pull once
38+ p.pull()
39+ p.code.pull.assert_called()
40+ # pull again, not dirty no need to pull
41+ p.code.pull.reset_mock()
42+ p.pull()
43+ self.assertFalse(p.code.pull.called)

Subscribers

People subscribed via source and target branches