def test_server_response(self): # will require automatic test server to shutdown, for now, just to it by hand before running this test if not is_test_server_running(): with self.assertRaises(ApiException): SquadApi.get('/api/groups') else: self.assertTrue(SquadApi.get('/api/groups') is not None)
def setUp(self): SquadApi.configure('http://localhost:8000')
#!/usr/bin/env python3 import jinja2 import sys sys.path.append('..') from squad_client.api import SquadApi from squad_client.models import Squad # Configure SQUAD url SquadApi.configure(url='https://qa-reports.linaro.org/') # Generate a report with all groups groups = Squad().groups() templateLoader = jinja2.FileSystemLoader(searchpath="./") templateEnv = jinja2.Environment(loader=templateLoader) TEMPLATE_FILE = "example_template.html" template = templateEnv.get_template(TEMPLATE_FILE) outputText = template.render(groups=groups.values()) with open('generated_report.html', 'w') as reportFile: reportFile.write(outputText)
#!/usr/bin/env python3 import unittest from squad_client.api import SquadApi from squad_client.models import Squad, Group, Project, Build, TestJob, TestRun, Test, Suite, Environment, Backend, EmailTemplate, KnownIssue, SuiteMetadata, Annotation, MetricThreshold, Report from squad_client.utils import first SquadApi.configure(url='http://localhost:8000') class SquadTest(unittest.TestCase): def setUp(self): self.squad = Squad() def test_groups(self): groups = self.squad.groups() self.assertTrue(True, len(groups)) def test_not_found_groups(self): groups = self.squad.groups(name__startswith='no group with this name') self.assertEqual(0, len(groups)) def test_groups_with_count(self): four_groups = self.squad.groups(count=4) self.assertEqual(4, len(four_groups)) def test_not_found_group(self): not_found_group = self.squad.group('this-group-does-not-really-exist') self.assertEqual(None, not_found_group)
def test_out_of_domain_object_url(self): with self.assertRaises(ApiException): SquadApi.get('http://some.other.url')
def test_malformed_url(self): with self.assertRaises(ApiException): SquadApi.configure('http:/malformed/url')
#!/usr/bin/env python3 import os import jinja2 import sys sys.path.append('..') from squad_client.api import SquadApi from squad_client.models import Squad SquadApi.configure(url='https://qa-reports.linaro.org/', token=os.getenv('QA_REPORTS_TOKEN')) group = Squad().group('schneider') project = group.project('schneider') build = project.build('184') testruns = build.testruns(bucket_suites=True, completed=True).values() templateLoader = jinja2.FileSystemLoader(searchpath="./") templateEnv = jinja2.Environment(loader=templateLoader) TEMPLATE_FILE = "schneider_template.html" template = templateEnv.get_template(TEMPLATE_FILE) outputText = template.render(group=group, project=project, build=build, testruns=testruns) with open('schneider_generated_report.html', 'w') as reportFile: reportFile.write(outputText)