xref: /OK3568_Linux_fs/yocto/bitbake/lib/toaster/tests/commands/test_lsupdates.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#! /usr/bin/env python3
2*4882a593Smuzhiyun#
3*4882a593Smuzhiyun# BitBake Toaster Implementation
4*4882a593Smuzhiyun#
5*4882a593Smuzhiyun# Copyright (C) 2016 Intel Corporation
6*4882a593Smuzhiyun#
7*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0-only
8*4882a593Smuzhiyun#
9*4882a593Smuzhiyun
10*4882a593Smuzhiyunfrom django.test import TestCase
11*4882a593Smuzhiyunfrom django.core import management
12*4882a593Smuzhiyun
13*4882a593Smuzhiyunfrom orm.models import Layer_Version, Machine, Recipe
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun
16*4882a593Smuzhiyunclass TestLayerIndexUpdater(TestCase):
17*4882a593Smuzhiyun    def test_run_lsupdates_command(self):
18*4882a593Smuzhiyun        # Load some release information for us to fetch from the layer index
19*4882a593Smuzhiyun        management.call_command('loaddata', 'poky')
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun        old_layers_count = Layer_Version.objects.count()
22*4882a593Smuzhiyun        old_recipes_count = Recipe.objects.count()
23*4882a593Smuzhiyun        old_machines_count = Machine.objects.count()
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun        # Now fetch the metadata from the layer index
26*4882a593Smuzhiyun        management.call_command('lsupdates')
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun        self.assertTrue(Layer_Version.objects.count() > old_layers_count,
29*4882a593Smuzhiyun                        "lsupdates ran but we still have no more layers!")
30*4882a593Smuzhiyun        self.assertTrue(Recipe.objects.count() > old_recipes_count,
31*4882a593Smuzhiyun                        "lsupdates ran but we still have no more Recipes!")
32*4882a593Smuzhiyun        self.assertTrue(Machine.objects.count() > old_machines_count,
33*4882a593Smuzhiyun                        "lsupdates ran but we still have no more Machines!")
34