Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 3583EE00C8B; Fri, 16 Sep 2016 09:00:24 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [209.85.220.41 listed in list.dnswl.org] Received: from mail-pa0-f41.google.com (mail-pa0-f41.google.com [209.85.220.41]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 0ABA7E00B74 for ; Fri, 16 Sep 2016 09:00:18 -0700 (PDT) Received: by mail-pa0-f41.google.com with SMTP id wk8so27253569pab.1 for ; Fri, 16 Sep 2016 09:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=bSmHl5cpI4Y5CqRN1TLzN10MdEBA7PLnIVbwlX3SEyw=; b=IC6+sKYvELs8c5pVNawa9+QtcpGaSdpL5BmHIyeAzt0fxOiw72XPwlvjeUr+EJlsDT wdOFoPYS3gZ/uQxrUwWCiny4mFrsXqzSV0jz5O30pAX70jvMZeOzQ5TaoJtyQjG4Ibaa D7xqaUZUNOd862IRPm8DS0uHf2QKGOO53LqKdYLh151UFH4j8lNbW/MLrMq1PuSUbPoo cM3U8t1eZopNGZEMuCIWwkSLyR5d+qnsVMvmMMJujgBJJS4j5nsccs4YNRqCWLwC9Sqs Kw33RNRjb+yP/fecc5vR3wAB2s8CAGy1Jmm0HnO9x8KdttMctw0qhM3mhpi1HTgwJh5w yYEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bSmHl5cpI4Y5CqRN1TLzN10MdEBA7PLnIVbwlX3SEyw=; b=S7NLj01WBPdmwecsizauUn5uBldEpjliwKVb6S7asDCNW2zLxg93BfKM5gu2iGGkQi 2y0rYcLofDMLJGmF9R/A7btprI8Y76eEfuFekCexQRF0gO8QwiWnX6O6iRNEXbRFn66t clRH66Ru7FAjSMUYsU/4V5UtcpAdmMNG0jiefJXqHy04+qgnfRnpfPnJdgJ+dStjDiA7 vqI8L6s9a+8aIMAc88eWSmoSDPsLqAE5LQDMkO5aZc3Ia7zSPZzb486sj2L5/nNb0IAn TONer8IDUfC4B1IPQCIqTimlnSJjboUCHzRJf0djx9x3K3Jx0CE2FAoOsDp59gUGA0YQ uDVg== X-Gm-Message-State: AE9vXwNpv26DXo+1gwtEt5Oe7kOHuY/e0mwMvHVYSnHKHlplmopklvc7P7ssrIf2bu11hC80 X-Received: by 10.66.227.4 with SMTP id rw4mr24261614pac.119.1474041617842; Fri, 16 Sep 2016 09:00:17 -0700 (PDT) Received: from orion.ger.corp.intel.com (fmdmzpr04-ext.fm.intel.com. [192.55.55.39]) by smtp.gmail.com with ESMTPSA id p4sm53258487pfp.60.2016.09.16.09.00.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Sep 2016 09:00:17 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Fri, 16 Sep 2016 17:00:06 +0100 Message-Id: <1474041606-11127-1-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [PATCH] toaster: Add tests to detect if we have missing db migrations X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Sep 2016 16:00:24 -0000 Based on the same test as found in patchwork by Damien Lespiau https://github.com/dlespiau/patchwork/blob/master/patchwork/tests/test_db.py Signed-off-by: Michael Wood --- bitbake/lib/toaster/tests/db/__init__.py | 0 bitbake/lib/toaster/tests/db/test_db.py | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 bitbake/lib/toaster/tests/db/__init__.py create mode 100644 bitbake/lib/toaster/tests/db/test_db.py diff --git a/bitbake/lib/toaster/tests/db/__init__.py b/bitbake/lib/toaster/tests/db/__init__.py new file mode 100644 index 0000000..e69de29 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 0000000..a0f5f6e --- /dev/null +++ b/bitbake/lib/toaster/tests/db/test_db.py @@ -0,0 +1,55 @@ +# The MIT License (MIT) +# +# Copyright (c) 2016 Damien Lespiau +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import sys + +try: + from StringIO import StringIO +except ImportError: + from io import StringIO + +from contextlib import contextmanager + +from django.core import management +from django.test import TestCase + + +@contextmanager +def capture(command, *args, **kwargs): + out, sys.stdout = sys.stdout, StringIO() + command(*args, **kwargs) + sys.stdout.seek(0) + yield sys.stdout.read() + sys.stdout = out + + +def makemigrations(): + management.call_command('makemigrations') + + +class MigrationTest(TestCase): + + def testPendingMigration(self): + """Make sure there's no pending migration.""" + + with capture(makemigrations) as output: + self.assertEqual(output, "No changes detected\n") -- 2.7.4