summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-09-18 19:37:53 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-21 21:58:06 +0100
commit6066729797fda93eff5c0a68fea46cc7ae0fa072 (patch)
tree4c2a27d55e67170ce03c0a69d92b2c3ee87a07d5 /bitbake/lib/toaster
parent7a3cccbd1aa4333df6ab46d87b4b1f39d1fe683d (diff)
downloadpoky-6066729797fda93eff5c0a68fea46cc7ae0fa072.tar.gz
bitbake: toaster: Add tests to detect if we have missing db migrations
Based on the same test as found in patchwork by Damien Lespiau https://github.com/dlespiau/patchwork/blob/master/patchwork/tests/test_db.py (Bitbake rev: 031cb194aaa1b6cc970fed3fa0d0dbd3ebac163f) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: bavery <brian.avery@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster')
-rw-r--r--bitbake/lib/toaster/tests/db/__init__.py0
-rw-r--r--bitbake/lib/toaster/tests/db/test_db.py55
2 files changed, 55 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/tests/db/__init__.py b/bitbake/lib/toaster/tests/db/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/bitbake/lib/toaster/tests/db/__init__.py
diff --git a/bitbake/lib/toaster/tests/db/test_db.py b/bitbake/lib/toaster/tests/db/test_db.py
new file mode 100644
index 0000000000..a0f5f6ec03
--- /dev/null
+++ b/bitbake/lib/toaster/tests/db/test_db.py
@@ -0,0 +1,55 @@
1# The MIT License (MIT)
2#
3# Copyright (c) 2016 Damien Lespiau
4#
5# Permission is hereby granted, free of charge, to any person obtaining a copy
6# of this software and associated documentation files (the "Software"), to deal
7# in the Software without restriction, including without limitation the rights
8# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9# copies of the Software, and to permit persons to whom the Software is
10# furnished to do so, subject to the following conditions:
11#
12# The above copyright notice and this permission notice shall be included in
13# all copies or substantial portions of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21# SOFTWARE.
22
23import sys
24
25try:
26 from StringIO import StringIO
27except ImportError:
28 from io import StringIO
29
30from contextlib import contextmanager
31
32from django.core import management
33from django.test import TestCase
34
35
36@contextmanager
37def capture(command, *args, **kwargs):
38 out, sys.stdout = sys.stdout, StringIO()
39 command(*args, **kwargs)
40 sys.stdout.seek(0)
41 yield sys.stdout.read()
42 sys.stdout = out
43
44
45def makemigrations():
46 management.call_command('makemigrations')
47
48
49class MigrationTest(TestCase):
50
51 def testPendingMigration(self):
52 """Make sure there's no pending migration."""
53
54 with capture(makemigrations) as output:
55 self.assertEqual(output, "No changes detected\n")