18 # |
18 # |
19 #Description: |
19 #Description: |
20 #=============================================================================== |
20 #=============================================================================== |
21 |
21 |
22 """ Testing ats4 framework. """ |
22 """ Testing ats4 framework. """ |
23 # pylint: disable-msg=E1101, C0302, W0142, W0603, R0902,R0903,R0912,R0915 |
23 # pylint: disable=E1101, C0302, W0142, W0603, R0902,R0903,R0912,R0915 |
24 #E1101 => Mocker shows mockery |
24 #E1101 => Mocker shows mockery |
25 #C0302 => too many lines |
25 #C0302 => too many lines |
26 #W0142 => used * or ** magic |
26 #W0142 => used * or ** magic |
27 #W0603 => used global |
27 #W0603 => used global |
28 #R* during refactoring |
28 #R* during refactoring |
300 step = steps.next() |
300 step = steps.next() |
301 assert step.findtext("./type") == "FileDownloadTask" |
301 assert step.findtext("./type") == "FileDownloadTask" |
302 params = step.findall("./parameters/parameter") |
302 params = step.findall("./parameters/parameter") |
303 #assert params[0].get("value") == "false" |
303 #assert params[0].get("value") == "false" |
304 assert params[0].get("value") == path(r"c:\data\ctc\ctcdata.txt") |
304 assert params[0].get("value") == path(r"c:\data\ctc\ctcdata.txt") |
305 if testtype == "withpkgfiles": |
|
306 assert params[1].get("value") == r"\\10.0.0.1\ctc_helium\builds\drop0\set1\ctcdata" |
|
307 else: |
|
308 assert params[1].get("value") == r"\\10.0.0.1\ctc_helium\builds\drop0\set0\ctcdata" |
|
309 |
|
310 #For the ctcdata.txt to be published on the build network drive |
|
311 step = steps.next() |
|
312 assert step.findtext("./type") == "FileDownloadTask" |
|
313 params = step.findall("./parameters/parameter") |
|
314 #assert params[0].get("value") == "true" |
|
315 assert params[0].get("value") == path(r"c:\data\ctc\ctcdata.txt") |
|
316 |
305 |
317 def check_ctc_start(steps): |
306 def check_ctc_start(steps): |
318 """Checks if CTC starts in ATS""" |
307 """Checks if CTC starts in ATS""" |
319 step = steps.next() |
308 step = steps.next() |
320 assert step.findtext("./type") == "CreateDirTask" |
309 assert step.findtext("./type") == "CreateDirTask" |
336 assert params[0].get("value") == path(r"c:\Shared\EUnit\logs\*") |
325 assert params[0].get("value") == path(r"c:\Shared\EUnit\logs\*") |
337 |
326 |
338 def check_diamonds_action(action): |
327 def check_diamonds_action(action): |
339 """ Testing Diamonds action. """ |
328 """ Testing Diamonds action. """ |
340 assert action.findtext("./type") == "DiamondsAction" |
329 assert action.findtext("./type") == "DiamondsAction" |
341 assert not action.findall("./parameters/parameter") |
|
342 |
330 |
343 def check_send_email_action(action, reportemail): |
331 def check_send_email_action(action, reportemail): |
344 """verifies if sening email option works""" |
332 """verifies if sening email option works""" |
345 assert action.findtext("./type") == "EmailAction" |
333 assert action.findtext("./type") == "EmailAction" |
346 params = action.findall("./parameters/parameter") |
334 params = action.findall("./parameters/parameter") |
532 pmd_files=self.pmd_files, |
520 pmd_files=self.pmd_files, |
533 trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set0", "tracelog.blx"), |
521 trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set0", "tracelog.blx"), |
534 trace_activation_files=self.trace_activation_files, |
522 trace_activation_files=self.trace_activation_files, |
535 ctc_enabled=self.atp["ctc_enabled"], |
523 ctc_enabled=self.atp["ctc_enabled"], |
536 custom_dir=None, |
524 custom_dir=None, |
|
525 dll_files={}, |
537 component_path=self.component_path) |
526 component_path=self.component_path) |
538 assert self.atp.sets[1] == dict(name="set1", |
527 assert self.atp.sets[1] == dict(name="set1", |
539 image_files=self.image_files, |
528 image_files=self.image_files, |
540 engine_ini_file=self.engine_ini_file, |
529 engine_ini_file=self.engine_ini_file, |
541 sis_files=self.sis_files, |
530 sis_files=self.sis_files, |
545 pmd_files=self.pmd_files, |
534 pmd_files=self.pmd_files, |
546 trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set1", "tracelog.blx"), |
535 trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set1", "tracelog.blx"), |
547 trace_activation_files=self.trace_activation_files, |
536 trace_activation_files=self.trace_activation_files, |
548 ctc_enabled=self.atp["ctc_enabled"], |
537 ctc_enabled=self.atp["ctc_enabled"], |
549 custom_dir=None, |
538 custom_dir=None, |
|
539 dll_files={}, |
550 component_path=self.component_path) |
540 component_path=self.component_path) |
551 |
541 |
552 assert self.atp.sets[2] == dict(name="set2", |
542 assert self.atp.sets[2] == dict(name="set2", |
553 data_files=self.data_files, |
543 data_files=self.data_files, |
554 config_files=self.config_files, |
544 config_files=self.config_files, |
562 pmd_files=self.pmd_files, |
552 pmd_files=self.pmd_files, |
563 trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set2", "tracelog.blx"), |
553 trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set2", "tracelog.blx"), |
564 trace_activation_files=self.trace_activation_files, |
554 trace_activation_files=self.trace_activation_files, |
565 ctc_enabled=self.atp["ctc_enabled"], |
555 ctc_enabled=self.atp["ctc_enabled"], |
566 custom_dir=None, |
556 custom_dir=None, |
|
557 dll_files={}, |
567 component_path=self.component_path) |
558 component_path=self.component_path) |
568 assert self.atp.sets[3] == dict(name="set3", |
559 assert self.atp.sets[3] == dict(name="set3", |
569 data_files=[], |
560 data_files=[], |
570 config_files=[], |
561 config_files=[], |
571 engine_ini_file=self.engine_ini_file, |
562 engine_ini_file=self.engine_ini_file, |
578 pmd_files=self.pmd_files, |
569 pmd_files=self.pmd_files, |
579 trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set3", "tracelog.blx"), |
570 trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set3", "tracelog.blx"), |
580 trace_activation_files=self.trace_activation_files, |
571 trace_activation_files=self.trace_activation_files, |
581 ctc_enabled=self.atp["ctc_enabled"], |
572 ctc_enabled=self.atp["ctc_enabled"], |
582 custom_dir=None, |
573 custom_dir=None, |
|
574 dll_files={}, |
583 component_path=self.component_path) |
575 component_path=self.component_path) |
584 |
576 |
585 assert self.atp.sets[4] == dict(name="set4", |
577 assert self.atp.sets[4] == dict(name="set4", |
586 data_files=[], |
578 data_files=[], |
587 config_files=[], |
579 config_files=[], |
595 pmd_files=self.pmd_files, |
587 pmd_files=self.pmd_files, |
596 trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set4", "tracelog.blx"), |
588 trace_path=self.atp.file_store.joinpath(u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§", "traces", "set4", "tracelog.blx"), |
597 trace_activation_files=self.trace_activation_files, |
589 trace_activation_files=self.trace_activation_files, |
598 ctc_enabled=self.atp["ctc_enabled"], |
590 ctc_enabled=self.atp["ctc_enabled"], |
599 custom_dir=None, |
591 custom_dir=None, |
|
592 dll_files={}, |
600 component_path=self.component_path) |
593 component_path=self.component_path) |
601 |
594 |
602 def test_post_actions_email(self): |
595 def test_post_actions_email(self): |
603 """ Testing the send email post-action. """ |
596 """ Testing the send email post-action. """ |
604 assert not self.atp.post_actions |
597 assert not self.atp.post_actions |
776 mocker.expect(test_plan["device_hwid"]).result("5425") |
769 mocker.expect(test_plan["device_hwid"]).result("5425") |
777 mocker.expect(test_plan["custom_dir"]).result("custom") |
770 mocker.expect(test_plan["custom_dir"]).result("custom") |
778 mocker.expect(test_plan.custom_dir).result(path(r"self.custom_dir")) |
771 mocker.expect(test_plan.custom_dir).result(path(r"self.custom_dir")) |
779 mocker.expect(test_plan["report_email"]).result(self.report_email) |
772 mocker.expect(test_plan["report_email"]).result(self.report_email) |
780 mocker.expect(test_plan["ctc_run_process_params"]).result(self.ctc_run_process_params) |
773 mocker.expect(test_plan["ctc_run_process_params"]).result(self.ctc_run_process_params) |
|
774 mocker.expect(test_plan["report_type"]).result("") |
781 |
775 |
782 if self.trace_enabled.lower() == "true": |
776 if self.trace_enabled.lower() == "true": |
783 mocker.expect(test_plan["trace_enabled"]).result("True") |
777 mocker.expect(test_plan["trace_enabled"]).result("True") |
784 else: |
778 else: |
785 mocker.expect(test_plan["trace_enabled"]).result("False") |
779 mocker.expect(test_plan["trace_enabled"]).result("False") |
832 # ("time-format", "HHmmss"))), |
826 # ("time-format", "HHmmss"))), |
833 ("DiamondsAction", ())]) |
827 ("DiamondsAction", ())]) |
834 self.mocker.replay() |
828 self.mocker.replay() |
835 self.test_plan = test_plan |
829 self.test_plan = test_plan |
836 self.gen = adg.Ats3TemplateTestDropGenerator() |
830 self.gen = adg.Ats3TemplateTestDropGenerator() |
|
831 self.gen.output_file = 'ats4drop0.zip' |
837 return self.gen.generate_xml(test_plan) |
832 return self.gen.generate_xml(test_plan) |
838 |
833 |
839 def test_basic_structure(self): |
834 def test_basic_structure(self): |
840 """ Check that the overall test.xml structure is valid. """ |
835 """ Check that the overall test.xml structure is valid. """ |
841 xml = self.generate_xml() |
836 xml = self.generate_xml() |
1191 mocker.expect(test_plan["ctc_enabled"]).result(self.ctc_enabled) |
1186 mocker.expect(test_plan["ctc_enabled"]).result(self.ctc_enabled) |
1192 mocker.expect(test_plan["custom_dir"]).result("custom1A") |
1187 mocker.expect(test_plan["custom_dir"]).result("custom1A") |
1193 mocker.expect(test_plan.custom_dir).result(path(r"self.custom_dir")) |
1188 mocker.expect(test_plan.custom_dir).result(path(r"self.custom_dir")) |
1194 mocker.expect(test_plan["ctc_run_process_params"]).result(self.ctc_run_process_params) |
1189 mocker.expect(test_plan["ctc_run_process_params"]).result(self.ctc_run_process_params) |
1195 mocker.expect(test_plan["report_email"]).result(self.report_email) |
1190 mocker.expect(test_plan["report_email"]).result(self.report_email) |
|
1191 mocker.expect(test_plan["report_type"]).result("") |
1196 if self.trace_enabled == "False": |
1192 if self.trace_enabled == "False": |
1197 mocker.expect(test_plan.sets).result([ |
1193 mocker.expect(test_plan.sets).result([ |
1198 dict(name="set0", image_files=self.image_files, data_files=self.data_files, |
1194 dict(name="set0", image_files=self.image_files, data_files=self.data_files, |
1199 config_files=self.config_files, testmodule_files=self.testmodule_files, |
1195 config_files=self.config_files, testmodule_files=self.testmodule_files, |
1200 engine_ini_file=self.engine_ini_file, test_harness=harness0,src_dst=self.src_dst0, |
1196 engine_ini_file=self.engine_ini_file, test_harness=harness0,src_dst=self.src_dst0, |
1238 |
1234 |
1239 self.mocker.replay() |
1235 self.mocker.replay() |
1240 self.test_plan = test_plan |
1236 self.test_plan = test_plan |
1241 |
1237 |
1242 self.gen = adg.Ats3TemplateTestDropGenerator() |
1238 self.gen = adg.Ats3TemplateTestDropGenerator() |
|
1239 self.gen.output_file = 'ats4drop0.zip' |
1243 return self.gen.generate_xml(test_plan) |
1240 return self.gen.generate_xml(test_plan) |
1244 # for thar in test_harness: |
1241 # for thar in test_harness: |
1245 # xml = self.generate_xml(thar) |
1242 # xml = self.generate_xml(thar) |
1246 # # Check basics. |
1243 # # Check basics. |
1247 # assert xml.find(".").tag == "test" |
1244 # assert xml.find(".").tag == "test" |
1569 mocker.expect(test_plan["trace_enabled"]).result("False") |
1566 mocker.expect(test_plan["trace_enabled"]).result("False") |
1570 mocker.expect(test_plan["custom_dir"]).result("CustomC") |
1567 mocker.expect(test_plan["custom_dir"]).result("CustomC") |
1571 mocker.expect(test_plan.custom_dir).result(path(r"self.custom_dir")) |
1568 mocker.expect(test_plan.custom_dir).result(path(r"self.custom_dir")) |
1572 mocker.expect(test_plan["ctc_run_process_params"]).result(self.ctc_run_process_params) |
1569 mocker.expect(test_plan["ctc_run_process_params"]).result(self.ctc_run_process_params) |
1573 mocker.expect(test_plan["report_email"]).result(self.report_email) |
1570 mocker.expect(test_plan["report_email"]).result(self.report_email) |
|
1571 mocker.expect(test_plan["report_type"]).result("") |
1574 mocker.expect(test_plan.sets).result([ |
1572 mocker.expect(test_plan.sets).result([ |
1575 dict(name="set0", image_files=self.image_files, sis_files=self.sis_files, |
1573 dict(name="set0", image_files=self.image_files, sis_files=self.sis_files, |
1576 engine_ini_file=self.engine_ini_file, test_harness=self.harness, ctc_enabled="False", component_path=self.component_path, custom_dir=None), |
1574 engine_ini_file=self.engine_ini_file, test_harness=self.harness, ctc_enabled="False", component_path=self.component_path, custom_dir=None), |
1577 ]) |
1575 ]) |
1578 mocker.expect(test_plan.post_actions).result([]) |
1576 mocker.expect(test_plan.post_actions).result([]) |
1579 self.mocker.replay() |
1577 self.mocker.replay() |
1580 self.test_plan = test_plan |
1578 self.test_plan = test_plan |
1581 |
1579 |
1582 self.gen = adg.Ats3TemplateTestDropGenerator() |
1580 self.gen = adg.Ats3TemplateTestDropGenerator() |
|
1581 self.gen.output_file = 'ats4drop0.zip' |
1583 return self.gen.generate_xml(test_plan) |
1582 return self.gen.generate_xml(test_plan) |
1584 |
1583 |
1585 def test_case_steps(self): |
1584 def test_case_steps(self): |
1586 """Checks cases in steps in the test.xml file""" |
1585 """Checks cases in steps in the test.xml file""" |
1587 xml = self.generate_xml() |
1586 xml = self.generate_xml() |
1610 for filename in self.sis_files: |
1609 for filename in self.sis_files: |
1611 step = steps.next() |
1610 step = steps.next() |
1612 assert step.findtext("./type") == "InstallSisTask" |
1611 assert step.findtext("./type") == "InstallSisTask" |
1613 params = step.findall("./parameters/parameter") |
1612 params = step.findall("./parameters/parameter") |
1614 assert params[-1].get("value") == "c:\\testframework\\" + ntpath.basename(filename) |
1613 assert params[-1].get("value") == "c:\\testframework\\" + ntpath.basename(filename) |
|
1614 |
|
1615 def test_ats_sut(): |
|
1616 opts = Bunch(file_store='', flash_images='', diamonds_build_url='', testrun_name='', device_type='', report_email='', test_timeout='', drop_file='', config_file='', target_platform='', data_dir='', build_drive='', sis_files='', harness='', trace_enabled='', specific_pkg='', ats4_enabled='true', device_hwid='') |
|
1617 |
|
1618 test_plan = ats3.Ats3TestPlan(opts) |
|
1619 component_parser = ats3.testconfigurator.Ats3ComponentParser(opts) |
|
1620 |
|
1621 test_plan.sets = [dict(name="set0", image_files='', test_harness='GENERIC', custom_dir=None, src_dst=[("file1.dll", r"c:\sys\bin\file1.dll", "testmodule:sut")])] |
|
1622 |
|
1623 generator = ats3.dropgenerator.Ats3TemplateTestDropGenerator() |
|
1624 generator.output_file = 'ats4drop0.zip' |
|
1625 xml = generator.generate_xml(test_plan) |
|
1626 #print et.tostring(xml.getroot()) |
|
1627 |
|
1628 steps = iter(xml.findall(".//task")) |
|
1629 steps.next() |
|
1630 steps.next() |
|
1631 step = steps.next() |
|
1632 assert step.findtext("./type") == "SymbianUnitTestTask" |
|
1633 params = step.findall("./parameters/parameter") |
|
1634 assert params[1].get("value") == r"-tests=c:\sys\bin\file1.dll -noprompt" |