[Toaster] [PATCH 3/3] toaster-tests: add test for cputime subpage

Smith, Elliot elliot.smith at intel.com
Mon Mar 7 11:24:35 PST 2016


So would you suggest removing these for now and adding a separate issue to
create equivalent Selenium tests, once the UI test framework is cleaned up?

Elliot

On 7 March 2016 at 19:17, Michael Wood <michael.g.wood at intel.com> wrote:

>
> Not really that keen on mixing HTML/content tests with the django
> functional unit tests. To me this would be better tested by the
> selenium/front end tests.
>
>
> On 07/03/16 12:21, Elliot Smith wrote:
>
>> Add a basic test which checks that the CPU time subpage for
>> the build dashboard shows both the User and System CPU time columns
>> by default.
>>
>> [YOCTO #8842]
>>
>> Signed-off-by: Elliot Smith <elliot.smith at intel.com>
>> ---
>>   bitbake/lib/toaster/toastergui/tests.py | 45
>> ++++++++++++++++++++++++++++++++-
>>   1 file changed, 44 insertions(+), 1 deletion(-)
>>
>> diff --git a/bitbake/lib/toaster/toastergui/tests.py
>> b/bitbake/lib/toaster/toastergui/tests.py
>> index 6b05916..b5862b7 100644
>> --- a/bitbake/lib/toaster/toastergui/tests.py
>> +++ b/bitbake/lib/toaster/toastergui/tests.py
>> @@ -29,7 +29,7 @@ from django.utils import timezone
>>   from orm.models import Project, Release, BitbakeVersion, Package,
>> LogMessage
>>   from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer,
>> Build
>>   from orm.models import Layer_Version, Recipe, Machine, ProjectLayer,
>> Target
>> -from orm.models import CustomImageRecipe, ProjectVariable
>> +from orm.models import CustomImageRecipe, ProjectVariable, Task
>>   from orm.models import Branch, CustomImagePackage
>>     import toastermain
>> @@ -1054,6 +1054,16 @@ class BuildDashboardTests(TestCase):
>>                                              started_on=now,
>>                                              completed_on=now)
>>   +        # target for build, so breadcrumb can display
>> +        Target.objects.create(build=self.build1, target='bash',
>> task='build')
>> +
>> +        # layer_version, recipe and task for build, so CPU time data can
>> display
>> +        layer = Layer.objects.create()
>> +        layer_version = Layer_Version.objects.create(layer=layer)
>> +        recipe = Recipe.objects.create(name='zlib',
>> layer_version=layer_version)
>> +        Task.objects.create(build=self.build1, recipe=recipe, order=1,
>> +                            outcome=Task.OUTCOME_SUCCESS)
>> +
>>           # exception
>>           msg1 = 'an exception was thrown'
>>           self.exception_message = LogMessage.objects.create(
>> @@ -1123,3 +1133,36 @@ class BuildDashboardTests(TestCase):
>>           section of the page
>>           """
>>           self._check_for_log_message(self.critical_message)
>> +
>> +    def test_cputime(self):
>> +        """
>> +        Check that the system and user CPU time columns are displayed
>> +        when the cputime subpage is shown
>> +        """
>> +        url = reverse('cputime', args=(self.build1.id,))
>> +        response = self.client.get(url, follow=True)
>> +        soup = BeautifulSoup(response.content)
>> +
>> +        # check nav item is highlighted
>> +        elements = soup.select('#nav li.active')
>> +        self.assertEquals(len(elements), 1,
>> +                          'should be one active nav element, ' +
>> +                          'but found %s' % len(elements))
>> +        link_text = elements[0].find('a').text.strip()
>> +        self.assertEquals(link_text, 'CPU time',
>> +                          'active nav element should have text "CPU
>> time", ' +
>> +                          'but text was %s' % link_text)
>> +
>> +        # check page heading
>> +        heading = soup.select('.page-header h1')[0]
>> +        self.assertEquals(heading.text.strip(), 'CPU time')
>> +
>> +        # check CPU column headings are both present
>> +        cpu_time_headings = ['System CPU time', 'User CPU time']
>> +        table_heading_links = soup.select('#otable th a')
>> +        for link in table_heading_links:
>> +            if link.text.strip() in cpu_time_headings:
>> +                cpu_time_headings.remove(link.text)
>> +        self.assertEquals(len(cpu_time_headings), 0,
>> +                          'Both CPU time headings (user, system) ' +
>> +                          'must be present; missing %s' %
>> cpu_time_headings)
>>
>
> ---------------------------------------------------------------------
> Intel Corporation (UK) Limited
> Registered No. 1134945 (England)
> Registered Office: Pipers Way, Swindon SN3 1RJ
> VAT No: 860 2173 47
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
> --
> _______________________________________________
> toaster mailing list
> toaster at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/toaster
>



-- 
Elliot Smith
Software Engineer
Intel Open Source Technology Centre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/toaster/attachments/20160307/eeb84843/attachment.html>


More information about the toaster mailing list