buildframework/helium/sf/python/pythoncore/lib/pythoncorecpythontests/test_ats4_aste.py
changeset 587 85df38eb4012
child 628 7c4a911dc066
equal deleted inserted replaced
217:0f5e3a7fb6af 587:85df38eb4012
       
     1 # -*- coding: latin-1 -*-
       
     2 
       
     3 #============================================================================ 
       
     4 #Name        : test_ats4_aste.py 
       
     5 #Part of     : Helium 
       
     6 
       
     7 #Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     8 #All rights reserved.
       
     9 #This component and the accompanying materials are made available
       
    10 #under the terms of the License "Eclipse Public License v1.0"
       
    11 #which accompanies this distribution, and is available
       
    12 #at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    13 #
       
    14 #Initial Contributors:
       
    15 #Nokia Corporation - initial contribution.
       
    16 #
       
    17 #Contributors:
       
    18 #
       
    19 #Description:
       
    20 #===============================================================================
       
    21 
       
    22 """ Testing ATS4 ASTE framework. """
       
    23 
       
    24 # pylint: disable-msg=E1101, R0903, R0911, R0912, W0603, W0142, R0902, R0201
       
    25 #E1101 => Mocker shows mockery
       
    26 #C0302 => too many lines
       
    27 #W0142 => used * or ** magic 
       
    28 #W0603 => used global
       
    29 #R* during refactoring
       
    30 
       
    31 from cStringIO import StringIO
       
    32 from xml.etree.ElementTree import fromstring
       
    33 from xml.etree import ElementTree as et
       
    34 import difflib
       
    35 import logging
       
    36 logging.getLogger().setLevel(logging.ERROR)
       
    37 import re
       
    38 import tempfile
       
    39 import zipfile
       
    40 import os
       
    41 
       
    42 from path import path # pylint: disable-msg=F0401
       
    43 import mocker # pylint: disable-msg=F0401
       
    44 
       
    45 import ats3.aste
       
    46 
       
    47 TEST_PATH = None
       
    48 TEST_FILES = {}
       
    49 TEST_ASSET_FILES = {}
       
    50 TSRC = None
       
    51 OUTPUT = None
       
    52 TEST_ZIP_PATH = None
       
    53 
       
    54 # Shortcuts
       
    55 E = et.Element
       
    56 SE = et.SubElement
       
    57 
       
    58 _logger = logging.getLogger("test.ats4_aste")
       
    59 
       
    60 class Bunch(object):
       
    61     """ handle all the parameters """
       
    62     def __init__(self, **kwargs):
       
    63         self.__dict__.update(kwargs)
       
    64 
       
    65 def equal_xml(xml1, xml2):
       
    66     """Check the equality of the given XML snippets.
       
    67     
       
    68     Tag name equality:
       
    69     
       
    70     >>> equal_xml('<a/>', '<a/>')
       
    71     True
       
    72     >>> equal_xml('<a/>', '<b/>')
       
    73     False
       
    74     
       
    75     Attribute equality:
       
    76     
       
    77     >>> equal_xml('<a k="v"/>', '<a k="v"/>')
       
    78     True
       
    79     >>> equal_xml('<a k="v"/>', '<a k="w"/>')
       
    80     False
       
    81     
       
    82     Text content equality:
       
    83     
       
    84     >>> equal_xml('<a>v</a>', '<a>v</a>')
       
    85     True
       
    86     >>> equal_xml('<a>v</a>', '<a>w</a>')
       
    87     False
       
    88     >>> equal_xml('<a>v</a>', '<a></a>')
       
    89     False
       
    90     
       
    91     Text content equality when whitespace differs:
       
    92     >>> equal_xml('<a>v</a>', '<a>v </a>')
       
    93     True
       
    94 
       
    95     Equality of child elements:
       
    96     
       
    97     >>> equal_xml('<a><b><c k="v"/></b></a>', '<a><b><c k="v"/></b></a>')
       
    98     True
       
    99     >>> equal_xml('<a><b><c k="v"/></b></a>', '<a><b><c k="w"/></b></a>')
       
   100     False
       
   101     >>> equal_xml('<a><b><c k="v"/>v</b></a>', '<a><b><c k="v"/>w</b></a>')
       
   102     False
       
   103     >>> equal_xml('<a><b><c k="v"/>v</b></a>', '<a><b><c k="v"/>v </b></a>')
       
   104     True
       
   105     
       
   106     """
       
   107     if isinstance(xml1, basestring):
       
   108         xml1 = fromstring(xml1)
       
   109     if isinstance(xml2, basestring):
       
   110         xml2 = fromstring(xml2)
       
   111     if xml1.tag != xml2.tag:
       
   112         return False
       
   113     if xml1.attrib != xml2.attrib:
       
   114         return False
       
   115     if xml1.text:
       
   116         if not xml2.text:
       
   117             return False
       
   118     if xml2.text:
       
   119         if not xml1.text:
       
   120             return False
       
   121     if xml1.text and xml2.text and xml1.text.strip() != xml2.text.strip():
       
   122         return False
       
   123     if xml1.tail is not None and xml2.tail is not None:
       
   124         if xml1.tail.strip() != xml2.tail.strip():
       
   125             return False
       
   126     elif xml1.tail != xml2.tail:
       
   127         return False
       
   128     children1 = list(xml1.getchildren())
       
   129     children2 = list(xml2.getchildren())
       
   130     if len(children1) != len(children2):
       
   131         return False
       
   132     for child1, child2 in zip(children1, children2):
       
   133         return equal_xml(child1, child2)
       
   134     return True        
       
   135 
       
   136 
       
   137 def setup_module():
       
   138     """ setup any values needed for the tests"""
       
   139     global TEST_PATH, OUTPUT, TEST_ZIP_PATH
       
   140     TEST_PATH = path(tempfile.mkdtemp())
       
   141     OUTPUT = TEST_PATH.joinpath("TestAsset")
       
   142     TEST_ZIP_PATH = TEST_PATH.joinpath("test_zip")
       
   143     asset = TEST_PATH
       
   144     component = TEST_PATH
       
   145     component.joinpath("group").makedirs()
       
   146     for path_parts in (("output", "images", "file1.fpsx"),
       
   147                        ("output", "images", "file2.fpsx")):
       
   148         filename = component.joinpath(*path_parts)
       
   149         if not filename.parent.exists():
       
   150             filename.parent.makedirs()
       
   151         filename.touch()
       
   152         TEST_FILES.setdefault(path_parts[1], []).append(file)
       
   153     for path_parts in (("TestAsset", "Localisation", "S60", "localisation.txt"),
       
   154                        ("TestAsset", "TestCases", "TC_100_Test0", "file1.sis"),
       
   155                        ("TestAsset", "TestCases", "TC_100_Test0", "file2.tcf"),
       
   156                        ("TestAsset", "Tools", "TestCaseCreator", "test_creator.ini"),
       
   157                        ("TestAsset", "testdrop.xml"),):
       
   158         filename = asset.joinpath(*path_parts)
       
   159         if not filename.parent.exists():
       
   160             filename.parent.makedirs()
       
   161         filename.touch()
       
   162         TEST_ASSET_FILES.setdefault(path_parts[1], []).append(file)
       
   163     try:
       
   164         zip_component = TEST_ZIP_PATH
       
   165         filename = zip_component.joinpath("TestAsset.zip")
       
   166         if not filename.parent.exists():
       
   167             filename.parent.makedirs()
       
   168         filename.touch()
       
   169         zfile = zipfile.ZipFile(zip_component.joinpath("TestAsset.zip"), "w", zipfile.ZIP_DEFLATED)
       
   170         for p_temp in TEST_ASSET_FILES:
       
   171             print p_temp
       
   172             zfile.write(p_temp)
       
   173         zfile.close()
       
   174         TEST_ASSET_FILES.setdefault("ZIP", []).append(file)
       
   175     except OSError:
       
   176         print "Got except OSError. Continuing...\n"  
       
   177         
       
   178 
       
   179 def teardown_module():
       
   180     """ tidy up after all the tests have run"""
       
   181     path(TEST_PATH).rmtree()
       
   182 
       
   183 
       
   184 class TestTestPlan(mocker.MockerTestCase):
       
   185     """ the main test"""
       
   186     def __init__(self, methodName="runTest"):
       
   187         mocker.MockerTestCase.__init__(self, methodName)
       
   188         
       
   189     def setUp(self):
       
   190         """setup the values required for this test"""
       
   191         opts = Bunch(testrun_name="testrun", harness="ASTE", 
       
   192                      device_type="product", plan_name="ats3_test_plan", diamonds_build_url="",
       
   193                      software_version="W810", software_release="SPP 51.32", device_language="English",
       
   194                      testasset_location=TEST_PATH.joinpath("TestAsset"), testasset_caseids="100",repeat="1", report_email="",
       
   195                      file_store=path(), test_timeout="60", device_hwid="5425", test_type="smoke")
       
   196         self.tp_temp = ats3.aste.AsteTestPlan(opts)
       
   197         self.image_files = TEST_FILES["images"]
       
   198         self.test_timeout = self.tp_temp["test_timeout"]
       
   199         self.device_hwid = self.tp_temp["device_hwid"]
       
   200         self.test_harness = self.tp_temp["harness"]
       
   201         self.device_language = self.tp_temp["device_language"]
       
   202         self.software_release = self.tp_temp["software_release"]
       
   203         self.software_version = self.tp_temp["software_version"]
       
   204         self.testasset_caseids = self.tp_temp["testasset_caseids"]
       
   205         self.testasset_location = self.tp_temp["testasset_location"]
       
   206         self.test_type = self.tp_temp["test_type"]
       
   207         
       
   208         if self.testasset_location != "":
       
   209             self.test_asset_testcases = [self.testasset_location.joinpath("TestCases", "TC_100_Test0", "file1.sis"), self.testasset_location.joinpath("TestCases", "TC_100_Test0", "file2.tcf")]
       
   210             self.test_asset_tools = [self.testasset_location.joinpath("Tools", "TestCaseCreator", "test_creator.ini")]
       
   211             self.test_asset_localisation = [self.testasset_location.joinpath("Localisation", "S60", "localisation.txt")]
       
   212             self.test_asset_testdrop = self.testasset_location.joinpath("testdrop.xml")
       
   213         else:
       
   214             self.test_asset_testcases = TEST_ASSET_FILES["TestCases"]
       
   215             self.test_asset_tools = TEST_ASSET_FILES["Tools"]
       
   216             self.test_asset_localisation = TEST_ASSET_FILES["Localisation"]
       
   217             self.test_asset_testdrop = TEST_ASSET_FILES["testdrop.xml"]
       
   218 
       
   219 
       
   220     def test_creation(self):
       
   221         """test the creation"""
       
   222         assert self.tp_temp["testrun_name"] == "testrun"
       
   223         assert self.tp_temp["harness"] == "ASTE"
       
   224         assert self.tp_temp["device_type"] == "product"
       
   225 
       
   226     def test_insert_set(self):
       
   227         """ test insert a set"""
       
   228         self.tp_temp.insert_set(image_files=self.image_files,
       
   229                            test_timeout=self.test_timeout)
       
   230         
       
   231         assert self.tp_temp.sets[0] == dict(name="set0",
       
   232                                        image_files=self.image_files,
       
   233                                        test_timeout=self.test_timeout,
       
   234                                        test_harness=self.test_harness)
       
   235 
       
   236     def test_post_actions_email(self):
       
   237         """test the post test actions email sent"""
       
   238         assert not self.tp_temp.post_actions
       
   239         receiver = "joe.average@example.com"
       
   240         self.tp_temp.report_email = receiver
       
   241         assert len(self.tp_temp.post_actions) == 1
       
   242         action, items = self.tp_temp.post_actions[0]
       
   243         items = dict(items)
       
   244         assert action == "SendEmailAction"
       
   245         assert items["to"] == receiver
       
   246 
       
   247     def test_post_actions_ats3_report_only(self):
       
   248         """test the post test actions only a report sent"""
       
   249         file_store = path("path/to/files")
       
   250         self.tp_temp.file_store = file_store
       
   251         self.tp_temp.harness = "EUNIT"
       
   252         assert len(self.tp_temp.post_actions) == 2
       
   253         action, items = self.tp_temp.post_actions[0]
       
   254         items = dict(items)
       
   255         assert action == "FileStoreAction"
       
   256         assert items["report-type"] == "ATS_REPORT"
       
   257         assert items["to-folder"].startswith(file_store)
       
   258         assert items["to-folder"].endswith("ATS3_REPORT")
       
   259 
       
   260     def test_post_actions_aste(self):
       
   261         """test the post actions for ASTE"""
       
   262         file_store = path("path/to/files")
       
   263         self.tp_temp.file_store = file_store
       
   264         assert len(self.tp_temp.post_actions) == 2
       
   265         action, items = self.tp_temp.post_actions[1]
       
   266         items = dict(items)
       
   267         assert action == "FileStoreAction"
       
   268         assert items["report-type"] == "ASTE_REPORT"
       
   269         assert items["to-folder"].startswith(file_store)
       
   270         assert items["to-folder"].endswith("ASTE_REPORT")
       
   271 
       
   272     def test_post_actions_diamonds(self):
       
   273         """test the post test actions that diamonds is informed"""
       
   274         self.tp_temp.diamonds_build_url = "http://diamonds.nmp.company.com/diamonds/builds/1234"
       
   275         assert len(self.tp_temp.post_actions) == 1
       
   276         action, items = self.tp_temp.post_actions[0]
       
   277         assert action == "DiamondsAction"
       
   278         assert not items
       
   279 
       
   280 
       
   281 class TestXMLGeneration(mocker.MockerTestCase):
       
   282     """
       
   283     Unit tests for the test.xml generation.
       
   284     """    
       
   285 
       
   286     def __init__(self, methodName="runTest"):
       
   287         self.image_files = None
       
   288         self.report_email = None
       
   289         self.diamonds_build_url = None
       
   290         self.test_harness = None
       
   291         self.file_store = None
       
   292         self.testasset_location = None
       
   293         self.test_plan = None
       
   294         self.gen = None
       
   295         mocker.MockerTestCase.__init__(self, methodName)
       
   296         
       
   297         
       
   298     def generate_xml(self):
       
   299         """ generate the XML """
       
   300         def files(*paths):
       
   301             """get list of tsrc files"""
       
   302             return [TEST_PATH.joinpath(p) for p in paths]
       
   303         self.image_files = files("output/images/file1.fpsx", "output/images/file2.fpsx")
       
   304         self.report_email = "test.receiver@company.com"
       
   305         self.diamonds_build_url = "http://diamonds.nmp.company.com/diamonds/builds/1234"
       
   306         self.test_harness = "ASTE"
       
   307         self.file_store = path(r"path/to/reports")
       
   308         self.testasset_location = OUTPUT
       
   309         
       
   310         self.mocker.restore()
       
   311         test_plan = self.mocker.mock(count=False)
       
   312         mocker.expect(test_plan["testrun_name"]).result("test")
       
   313         mocker.expect(test_plan["harness"]).result("ASTE")
       
   314         mocker.expect(test_plan["device_type"]).result("product")
       
   315         mocker.expect(test_plan["plan_name"]).result("test plan")
       
   316         mocker.expect(test_plan["diamonds_build_url"]).result(self.diamonds_build_url)
       
   317         mocker.expect(test_plan["test_timeout"]).result("60")
       
   318         mocker.expect(test_plan["device_hwid"]).result("5425")
       
   319         mocker.expect(test_plan["testasset_location"]).result(self.testasset_location)
       
   320         mocker.expect(test_plan["testasset_caseids"]).result("100")
       
   321         mocker.expect(test_plan["report_email"]).result(self.report_email)
       
   322         mocker.expect(test_plan["software_release"]).result("SPP 51.32")
       
   323         mocker.expect(test_plan["software_version"]).result("W810")
       
   324         mocker.expect(test_plan["device_language"]).result("English")
       
   325         mocker.expect(test_plan["test_type"]).result("smoke")
       
   326         mocker.expect(test_plan["temp_directory"]).result(TEST_PATH)
       
   327         mocker.expect(test_plan.sets).result([
       
   328             dict(name="set0", image_files=self.image_files, test_harness="ASTE")])
       
   329         mocker.expect(test_plan.post_actions).result([
       
   330             ("EmailAction", (("subject", "Release testing"),
       
   331                                  ("to", self.report_email))),
       
   332 #            ("FileStoreAction", (("to-folder", self.file_store),
       
   333 #                                 ("report-type", "ATS_REPORT"),
       
   334 #                                 ("date-format", "yyyyMMdd"),
       
   335 #                                 ("time-format", "HHmmss"))),
       
   336 #            ("FileStoreAction", (("to-folder", self.file_store),
       
   337 #                                 ("report-type", "ASTE_REPORT"),
       
   338 #                                 ("run-log", "true"),
       
   339 #                                 ("date-format", "yyyyMMdd"),
       
   340 #                                 ("time-format", "HHmmss"))),
       
   341             ("DiamondsAction", ())
       
   342         ])
       
   343         
       
   344         self.mocker.replay()
       
   345         self.test_plan = test_plan
       
   346         
       
   347         self.gen = ats3.aste.AsteTemplateTestDropGenerator()
       
   348         return self.gen.generate_xml(test_plan)
       
   349 
       
   350     def test_basic_structure(self):
       
   351         """Check that the overall test.xml structure is valid."""
       
   352         _ = self.generate_xml()
       
   353         # Check basics.
       
   354 #        assert xml.find(".").tag == "test"
       
   355 #        assert xml.find("./name").text == "test"
       
   356 #        assert xml.find("./buildid").text == self.diamonds_build_url
       
   357 #        assert xml.find("./target").tag
       
   358 #        assert xml.find("./target/device").tag
       
   359 #        harness, hardware, device_hwid = xml.findall("./target/device/property")
       
   360 #        softwareVersion, softwareRelease, deviceLanguage = xml.findall("./target/device/setting")
       
   361 #        assert harness.get("value") == "ASTE"
       
   362 #        assert hardware.get("value") == "product"
       
   363 #        assert softwareVersion.get("value") == "W810"
       
   364 #        assert softwareRelease.get("value") == "SPP 51.32"
       
   365 #        assert deviceLanguage.get("value") == "English"
       
   366 #        assert device_hwid.get("value") == "5425"
       
   367 #        
       
   368 #        # Check generation of the test plan.
       
   369 #        assert xml.find("./plan").get("name") == "Plan smoke product"
       
   370 #        assert xml.find("./plan/session").tag 
       
   371 #        sets = xml.findall("./plan/session/set")
       
   372 #        assert len(sets) == 1
       
   373 #        assert sets[0].get("name") == "set0"
       
   374 #        assert sets[0].find("./target/device").tag
       
   375 
       
   376     def test_set_structure(self):
       
   377         """Check that a <set> element's structure is valid."""
       
   378         _ = self.generate_xml()
       
   379 #        tstset = xml.find("./plan/session/set")
       
   380 #        assert tstset.tag
       
   381 #        case = tstset.find("./case")
       
   382 #        assert case.tag
       
   383 #        assert case.get("name") == "set0 case"                
       
   384         
       
   385     def test_case_flash_elems(self):
       
   386         """ Test case flash elems. """
       
   387         xml = self.generate_xml()
       
   388         found = False
       
   389         for case in xml.findall(".//task"):
       
   390             if case.find('type').text == 'FlashTask':
       
   391                 found = True
       
   392                 flashes = case.findall("./parameters/parameter")
       
   393                 assert len(flashes) == len(self.image_files)
       
   394                 for i, flash_file in enumerate(self.image_files):
       
   395                     assert flashes[i].get("name") == "image-" + str(i + 1)
       
   396                     assert flashes[i].get("value") == "ATS3Drop\\images\\" + flash_file.name
       
   397         assert found
       
   398     
       
   399     def test_steps(self):
       
   400         """test the steps """
       
   401         xml = self.generate_xml()
       
   402         steps = iter(xml.findall(".//task"))
       
   403         _ = steps.next()
       
   404         _ = steps.next()
       
   405         self.check_executeasset_step(steps)
       
   406 
       
   407     def check_executeasset_step(self, steps):
       
   408         """ test execute as asset steps"""
       
   409         step = steps.next()
       
   410         assert step.findtext("./type") == "SetTestAssetPackageTask"
       
   411         params = step.findall("./parameters/parameter")
       
   412         assert params[0].get("value") == "ATS3Drop\\TestAssets\\TestAsset.zip"
       
   413 
       
   414     def test_post_actions(self):
       
   415         """Post actions are inserted into XML."""
       
   416         xml = self.generate_xml()        
       
   417         post_actions = xml.findall(".//action")
       
   418         self.check_send_email_action(post_actions[0])
       
   419 #        self.check_ats_report_action(post_actions[1])
       
   420 #        self.check_aste_report_action(post_actions[2])
       
   421         self.check_diamonds_action(post_actions[1])
       
   422 
       
   423     def check_send_email_action(self, action):
       
   424         """ check the email is sent"""
       
   425         assert action.findtext("./type") == "EmailAction"
       
   426         params = action.findall("./parameters/parameter")
       
   427         assert params[0].get("name") == "subject"
       
   428         #assert params[0].get("value") == "email subject"
       
   429         #assert params[1].get("name") == "type"
       
   430         #assert params[1].get("value") == "ATS3_REPORT"
       
   431         #assert params[2].get("name") == "send-files"
       
   432         #assert params[2].get("value") == "true"
       
   433         assert params[1].get("name") == "to"
       
   434         assert params[1].get("value") == self.report_email
       
   435 
       
   436     def check_ats_report_action(self, action):
       
   437         """check the ATS report is created"""
       
   438         assert action.findtext("./type") == "FileStoreAction"
       
   439         params = action.findall("./parameters/parameter")
       
   440         assert params[0].get("name") == "to-folder"
       
   441         assert params[0].get("value") == self.file_store
       
   442         assert params[1].get("name") == "report-type"
       
   443         assert params[1].get("value") == "ATS_REPORT"
       
   444         assert params[2].get("name") == "date-format"
       
   445         assert params[2].get("value") == "yyyyMMdd"
       
   446         assert params[3].get("name") == "time-format"
       
   447         assert params[3].get("value") == "HHmmss"
       
   448 
       
   449     def check_aste_report_action(self, action):
       
   450         """check the ASTE report is created"""
       
   451         assert action.findtext("./type") == "FileStoreAction"
       
   452         params = action.findall("./parameters/parameter")
       
   453         assert params[0].get("name") == "to-folder"
       
   454         assert params[0].get("value") == self.file_store
       
   455         assert params[1].get("name") == "report-type"
       
   456         assert params[1].get("value") == "ASTE_REPORT"
       
   457         assert params[2].get("name") == "run-log"
       
   458         assert params[2].get("value") == "true"
       
   459         assert params[3].get("name") == "date-format"
       
   460         assert params[3].get("value") == "yyyyMMdd"
       
   461         assert params[4].get("name") == "time-format"
       
   462         assert params[4].get("value") == "HHmmss"
       
   463         
       
   464     def check_diamonds_action(self, action):
       
   465         """ check the diamonds actions are performed"""
       
   466         assert action.findtext("./type") == "DiamondsAction"
       
   467         assert not action.findall("./parameters/parameter")
       
   468     
       
   469     def test_files(self):
       
   470         """test the files"""
       
   471         _ = self.generate_xml()
       
   472 #        files = iter(xml.findall("./files/file"))
       
   473 #        assert files.next().text == r"ATS3Drop" + os.sep + "images" + os.sep + "file1.fpsx"
       
   474 #        assert files.next().text == r"ATS3Drop" + os.sep + "images" + os.sep + "file2.fpsx"
       
   475 #        assert files.next().text == r"ATS3Drop" + os.sep + "TestAssets" + os.sep + "TestAsset.zip"
       
   476 #        self.assertRaises(StopIteration, files.next)
       
   477         
       
   478     def test_generate_testasset_zip(self):
       
   479         """ test the generation of test assets"""
       
   480         self.generate_xml()
       
   481         if re.search(r"[.]zip", self.test_plan["testasset_location"]):
       
   482             pass
       
   483         else:
       
   484             strbuffer = StringIO()
       
   485             assert strbuffer == self.gen.generate_testasset_zip(self.test_plan, strbuffer)
       
   486             zfile = zipfile.ZipFile(strbuffer, "r")
       
   487             try:
       
   488                 contents = sorted(path(p).normpath() for p in zfile.namelist())
       
   489                 expected = sorted(path(p).normpath()
       
   490                                for p in [(r"Localisation" + os.sep + "S60" + os.sep + "localisation.txt"),
       
   491                                          (r"TestCases" + os.sep + "TC_100_Test0" + os.sep + "file1.sis"),
       
   492                                          (r"TestCases" + os.sep + "TC_100_Test0" + os.sep + "file2.tcf"),
       
   493                                          (r"Tools" + os.sep + "TestCaseCreator" + os.sep + "test_creator.ini"),
       
   494                                          (r"testdrop.xml")])
       
   495                 diff = difflib.context_diff(expected, contents)
       
   496                 assert contents == expected, "\n".join(diff)
       
   497             finally:
       
   498                 zfile.close()
       
   499         
       
   500     def test_generate_drop(self):
       
   501         """Manifest for ATS3Drop directory structure is generated."""
       
   502         xml = self.generate_xml()
       
   503         strbuffer = StringIO()
       
   504 
       
   505         self.gen.generate_drop(self.test_plan, xml, strbuffer)
       
   506         zfile = zipfile.ZipFile(strbuffer, "r")
       
   507         try:
       
   508             contents = sorted(path(p).normpath() for p in zfile.namelist())
       
   509             expected = sorted(path(p).normpath()
       
   510                            for p in [r"ATS3Drop" + os.sep + "images" + os.sep + "file1.fpsx",
       
   511                                      r"ATS3Drop" + os.sep + "images" + os.sep + "file2.fpsx",
       
   512                                      r"ATS3Drop" + os.sep + "TestAssets" + os.sep + "TestAsset.zip",
       
   513                                      r"test.xml"])
       
   514             diff = difflib.context_diff(expected, contents)
       
   515             assert contents == expected, "\n".join(diff)
       
   516         finally:
       
   517             zfile.close()