buildframework/helium/sf/python/pythoncore/lib/pythoncorecpythontests/test_archive.py
author wbernard
Thu, 22 Jul 2010 17:08:43 +0300
branchhelium-9.0
changeset 618 df88fead2976
parent 587 85df38eb4012
permissions -rw-r--r--
helium_9.0.5-4399343f4f50
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
#============================================================================ 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
#Name        : test_archive.py 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
#Part of     : Helium 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
#All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
#This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
#under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
#which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
#Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
#Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
#Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
#Description:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
#===============================================================================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
"""Test the archive.py module."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
from __future__ import with_statement
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
import os
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
import amara
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
import unittest
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
import archive
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
import configuration
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
import logging
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
import fileutils
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
import xml.dom.minidom
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
import tempfile
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
import test_fileutils
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
_logger = logging.getLogger('test.archive')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
root_test_dir = test_fileutils.root_test_dir
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
def setup_module():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
    """ Creates some test data files for file-related testing. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
    test_fileutils.setup_module()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
def teardown_module():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
    """ Cleans up test data files for file-related testing. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
    test_fileutils.teardown_module()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
class ArchivePreBuilderTest(unittest.TestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
    """Tests that an archive configuration file successfully creates an Ant exec file."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
    EXEC_FILE = "archive_create.ant.xml"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
    def test_ant_exec(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
        """Tests that an archive configuration file successfully creates an Ant exec file."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
        builder = configuration.NestedConfigurationBuilder(os.environ['TEST_DATA'] + '/data/archive_test_input.cfg.xml')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
        archiveConfigSet = builder.getConfiguration()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
        archivePreBuilder = archive.ArchivePreBuilder(archiveConfigSet, "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
        buildFilePath = os.path.join(root_test_dir, r'archive_test.ant.xml')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
        archivePreBuilder.write(buildFilePath)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
        build_file = open(buildFilePath)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
        build_file_content = build_file.read()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
        _logger.debug(build_file_content)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
        resultDoc = amara.parse(build_file_content)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
        build_file.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
        # The last target in the Ant file should be called 'all'. Other targets
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
        # are named stage1, stage2, etc.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
        self.assert_(resultDoc.project.target[-1].name == 'all')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
        os.remove(buildFilePath)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
class LogicalArchiveTest(unittest.TestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
    """tests Logical Archive feature"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
##    def setup(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
##        """Test setup."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
#        builder = configuration.NestedConfigurationBuilder(os.environ['TEST_DATA'] + '/data/archive_test.cfg.xml')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
#        self.archiveConfigSet = builder.getConfiguration()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
#        self.config = self.archiveConfigSet.getConfigurations()[0]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
#        self.archivePreBuilder = archive.ArchivePreBuilder(self.archiveConfigSet)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
    def test_manifest_files(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
        """ A LogicalArchive can create a correct manifest. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    83
        configDict = {'root.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    84
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    85
                  'archives.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
                  'name': 'manifest_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    87
                  'include': 'dir1/*.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    88
                  'archive.tool': '7za'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    89
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
        builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    94
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
        expectedPaths = [os.path.normpath('dir1/file1.txt')]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    96
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    99
        with open(includeFilePath) as f:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   100
            content = f.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   102
        print expectedPaths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   103
        content = [s.strip().lower() for s in content]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   104
        self.assert_(content == expectedPaths)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   105
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   106
    def test_empty_manifest_file(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   107
        """ A LogicalArchive can handle empty manifest. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   108
        configDict = {'root.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   109
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   110
                  'archives.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   111
                  'name': 'manifest_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   112
                  'include': 'nothing',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   113
                  'archive.tool': '7za'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   114
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   115
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   116
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   117
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   118
        builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   119
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   120
        expectedPaths = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   121
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   122
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   123
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   124
        with open(includeFilePath) as f:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   125
            content = f.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   126
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   127
        print expectedPaths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   128
        content = [s.strip().lower() for s in content]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   129
        self.assert_(content == expectedPaths)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   130
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   131
    def test_manifest_files_with_exclude_list(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   132
        """ A LogicalArchive can create a correct manifest. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   133
        excludelst = os.path.join(root_test_dir, 'exclude.lst')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   134
        flh = open(excludelst, 'w+')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   135
        flh.write("/epoc32/tools/variant/variant.cfg\n")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   136
        flh.write("\\epoc32\\tools\\abld.pl\n")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   137
        flh.write(os.path.join(root_test_dir, 'dir1', 'file1.txt') + "\n")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   138
        flh.write(os.path.join(root_test_dir, 'dir1/subdir1/subdir1_file.txt') + "\n")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   139
        flh.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   140
        configDict = {'root.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   141
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   142
                  'archives.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   143
                  'name': 'manifest_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   144
                  'include': 'dir1/**',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   145
                  'exclude.lst': excludelst,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   146
                  'archive.tool': '7za'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   147
                }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   148
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   149
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   150
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   151
        builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   152
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   153
        expectedPaths = [os.path.normpath('dir1/file2.doc'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   154
                         os.path.normpath('dir1/file3_no_extension'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   155
                         os.path.normpath('dir1/subdir2/subdir2_file_no_extension'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   156
                         os.path.normpath('dir1/subdir3/'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   157
                         ]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   158
        expectedPaths.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   159
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   160
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   161
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   162
        with open(includeFilePath) as f:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   163
            content = f.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   164
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   165
        print expectedPaths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   166
        content = [s.strip().lower() for s in content]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   167
        content.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   168
        self.assert_(content == expectedPaths)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   169
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   170
    def test_manifest_files_with_exclude_list_abs_nodrive(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   171
        """ A LogicalArchive can create a correct manifest with external list and drive. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   172
        rtd = os.path.splitdrive(os.path.abspath(root_test_dir))[1]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   173
        excludelst = os.path.join(root_test_dir, 'exclude.lst')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   174
        flh = open(excludelst, 'w+')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   175
        flh.write("/epoc32/tools/variant/variant.cfg\n")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   176
        flh.write("\\epoc32\\tools\\abld.pl\n")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   177
        flh.write(os.path.join(rtd, 'dir1', 'file1.txt') + "\n")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   178
        flh.write(os.path.join(rtd, 'dir1/subdir1/subdir1_file.txt') + "\n")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   179
        flh.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   180
        configDict = {'root.dir': os.path.abspath(root_test_dir),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   181
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   182
                  'archives.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   183
                  'name': 'manifest_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   184
                  'include': 'dir1/**',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   185
                  'exclude.lst': excludelst,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   186
                  'archive.tool': '7za'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   187
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   188
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   189
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   190
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   191
        builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   192
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   193
        expectedPaths = [os.path.normpath('dir1/file2.doc'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   194
                         os.path.normpath('dir1/file3_no_extension'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   195
                         os.path.normpath('dir1/subdir2/subdir2_file_no_extension'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   196
                         os.path.normpath('dir1/subdir3/'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   197
                         ]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   198
        expectedPaths.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   199
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   200
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   201
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   202
        with open(includeFilePath) as f:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   203
            content = f.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   204
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   205
            content = [s.strip().lower() for s in content]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   206
        else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   207
            content = [s.strip() for s in content]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   208
        content.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   209
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   210
        print expectedPaths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   211
        self.assert_(content == expectedPaths)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   212
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   213
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   214
    def test_distribution_policy_config(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   215
        """ tests the distribution policy files configuration"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   216
        expected_paths = [os.path.normpath('s60/component_public/component_public_file.txt'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   217
                         os.path.normpath('s60/component_public/Distribution.Policy.S60'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   218
                         os.path.normpath('s60/Distribution.Policy.S60'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   219
                         os.path.normpath('s60/missing/subdir/Distribution.Policy.S60'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   220
                         os.path.normpath('s60/missing/subdir/not_to_be_removed_0.txt'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   221
                         os.path.normpath('s60/UPPERCASE_MISSING/subdir/Distribution.Policy.S60'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   222
                         os.path.normpath('s60/UPPERCASE_MISSING/subdir/not_to_be_removed_0.txt'),]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   223
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   224
            for i in range(len(expected_paths)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   225
                expected_paths[i] = expected_paths[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   226
        self.do_distribution_policy_config(expected_paths, policy='0')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   227
         
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   228
        expected_paths = [os.path.normpath('s60/component_private/component_private_file.txt'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   229
                         os.path.normpath('s60/component_private/Distribution.Policy.S60'),]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   230
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   231
            for i in range(len(expected_paths)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   232
                expected_paths[i] = expected_paths[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   233
        self.do_distribution_policy_config(expected_paths, policy='1')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   234
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   235
        expected_paths = [os.path.normpath('s60/missing/subdir/another_subdir/to_be_removed_9999.txt'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   236
                          os.path.normpath('s60/missing/to_be_removed_9999.txt'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   237
                          os.path.normpath('s60/UPPERCASE_MISSING/subdir/another_subdir/to_be_removed_9999.txt'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   238
                          os.path.normpath('s60/UPPERCASE_MISSING/to_be_removed_9999.txt')]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   239
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   240
            for i in range(len(expected_paths)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   241
                expected_paths[i] = expected_paths[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   242
        self.do_distribution_policy_config(expected_paths, policy=archive.mappers.MISSING_POLICY)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   243
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   244
    def do_distribution_policy_config(self, expected_paths, policy):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   245
        """ . """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   246
        configDict = {'root.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   247
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   248
                  'archives.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   249
                  'name': 's60_policy_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   250
                  'include': 's60/',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   251
                  'distribution.policy.s60': policy,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   252
                  'selectors': 'policy',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   253
                  'archive.tool': '7za'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   254
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   255
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   256
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   257
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   258
        builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   259
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_test_includefile.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   260
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   261
        with open(includeFilePath) as f:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   262
            content = f.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   263
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   264
            content = [s.strip().lower() for s in content]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   265
        else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   266
            content = [s.strip() for s in content]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   267
        content.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   268
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   269
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   270
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   271
            expected_paths = [s.strip().lower() for s in expected_paths]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   272
        else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   273
            expected_paths = [s.strip() for s in expected_paths]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   274
        expected_paths.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   275
        print expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   276
        assert content == expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   277
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   278
    def test_split_manifest_file_unicode(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   279
        """ A LogicalArchive can split a manifest correctly. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   280
        configDict = {'root.dir': os.path.abspath(root_test_dir),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   281
                  'temp.build.dir': os.path.abspath(os.path.join(root_test_dir, 'temp_build_files')),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   282
                  'archives.dir': os.path.abspath(root_test_dir),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   283
                  'name': 'manifest_test_unicode',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   284
                  'max.files.per.archive': '1',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   285
                  'include': 'test_unicode/',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   286
                  'archive.tool': '7za'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   287
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   288
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   289
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   290
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   291
        manifest_file_path = builder.build_manifest(config)        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   292
        builder.manifest_to_commands(config, manifest_file_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   293
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   294
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_includefile.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   295
        includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_part01.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   296
        includeFilePath2 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_part02.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   297
        includeFilePath3 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_part03.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   298
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   299
        with open(includeFilePath) as f:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   300
            content = f.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   301
        with open(includeFilePath1) as f:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   302
            content1 = f.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   303
        with open(includeFilePath2) as f:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   304
            content2 = f.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   305
        with open(includeFilePath3) as f:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   306
            content3 = f.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   307
        print "content: ", content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   308
        print "content1: ", content1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   309
        print "content2: ", content2
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   310
        print "content3: ", content2
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   311
        content = [s.strip() for s in content]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   312
        self.assert_(len(content) == 3)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   313
        self.assert_(len(content1) == 1)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   314
        self.assert_(len(content2) == 1)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   315
        self.assert_(len(content3) == 1)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   316
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   317
    def test_distribution_policy_mapper_config(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   318
        """ Testing the policy mapper. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   319
        configDict = {'root.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   320
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   321
                  'archives.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   322
                  'name': 's60_policy_mapper_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   323
                  'include': 's60/',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   324
                  'archive.tool': '7za',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   325
                  'policy.zip2zip': 'true',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   326
                  'mapper': 'policy',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   327
                  'policy.csv': os.path.join(os.environ['TEST_DATA'], 'data/distribution.policy.id_status.csv'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   328
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   329
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   330
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   331
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   332
        manifest_file_path = builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   333
        cmds = builder.manifest_to_commands(config, manifest_file_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   334
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   335
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   336
        expected_paths = ['s60' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   337
                           's60' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   338
                           's60' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   339
                           's60' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   340
                           's60' + os.sep + 'Distribution.Policy.S60',                           
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   341
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'another_subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   342
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   343
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   344
                           's60' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   345
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'another_subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   346
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   347
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   348
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   349
                           's60' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   350
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   351
            for i in range(len(expected_paths)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   352
                expected_paths[i] = expected_paths[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   353
        expected_paths0 = ['s60' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   354
                           's60' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   355
                           's60' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   356
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   357
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   358
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   359
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   360
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   361
            for i in range(len(expected_paths0)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   362
                expected_paths0[i] = expected_paths0[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   363
        expected_paths1 = ['s60' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   364
                           's60' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   365
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   366
            for i in range(len(expected_paths1)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   367
                expected_paths1[i] = expected_paths1[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   368
        expected_paths9999 = ['s60' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   369
                              's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'another_subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   370
                              's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   371
                              's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'another_subdir' + os.sep + 'to_be_removed_9999.txt']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   372
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   373
            for i in range(len(expected_paths9999)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   374
                expected_paths9999[i] = expected_paths9999[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   375
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   376
        includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   377
        includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   378
        includeFilePath9999 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_9999.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   379
        includeFilePathInternal = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test.internal.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   380
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   381
        content = self.__read_manifest(includeFilePath)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   382
        expected_paths.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   383
        print "Content"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   384
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   385
        print "Expected"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   386
        print expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   387
        assert content == expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   388
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   389
        content = self.__read_manifest(includeFilePath0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   390
        expected_paths0.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   391
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   392
        print expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   393
        assert content == expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   394
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   395
        content = self.__read_manifest(includeFilePath1)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   396
        expected_paths1.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   397
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   398
        print expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   399
        assert content == expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   400
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   401
        content = self.__read_manifest(includeFilePath9999)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   402
        expected_paths9999.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   403
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   404
        print expected_paths9999
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   405
        assert content == expected_paths9999
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   406
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   407
        assert os.path.exists(includeFilePathInternal) == True
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   408
        print "Commands : ", cmds
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   409
        assert len(cmds) == 3
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   410
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   411
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   412
    def test_distribution_policy_mapper_config_no_zip2zip(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   413
        """ Testing the policy mapper. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   414
        configDict = {'root.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   415
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   416
                  'archives.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   417
                  'name': 's60_policy_mapper_test_noz2z',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   418
                  'include': 's60/',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   419
                  'archive.tool': '7za',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   420
                  'policy.zip2zip': 'false',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   421
                  'mapper': 'policy'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   422
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   423
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   424
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   425
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   426
        manifest_file_path = builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   427
        cmds = builder.manifest_to_commands(config, manifest_file_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   428
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   429
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   430
        expected_paths = ['s60' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   431
                           's60' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   432
                           's60' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   433
                           's60' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   434
                           's60' + os.sep + 'Distribution.Policy.S60',                           
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   435
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'another_subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   436
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   437
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   438
                           's60' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   439
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'another_subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   440
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   441
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   442
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   443
                           's60' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   444
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   445
            for i in range(len(expected_paths)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   446
                expected_paths[i] = expected_paths[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   447
        expected_paths0 = ['s60' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   448
                           's60' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   449
                           's60' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   450
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   451
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   452
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   453
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   454
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   455
            for i in range(len(expected_paths0)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   456
                expected_paths0[i] = expected_paths0[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   457
        expected_paths1 = ['s60' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   458
                           's60' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   459
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   460
            for i in range(len(expected_paths1)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   461
                expected_paths1[i] = expected_paths1[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   462
        expected_paths9999 = ['s60' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   463
                              's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'another_subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   464
                              's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   465
                              's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'another_subdir' + os.sep + 'to_be_removed_9999.txt']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   466
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   467
            for i in range(len(expected_paths9999)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   468
                expected_paths9999[i] = expected_paths9999[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   469
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   470
        expected_paths.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   471
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   472
        includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   473
        includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   474
        includeFilePath9999 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_9999.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   475
        includeFilePathInternal = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_noz2z.internal.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   476
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   477
        content = self.__read_manifest(includeFilePath)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   478
        expected_paths.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   479
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   480
        print expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   481
        assert content == expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   482
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   483
        content = self.__read_manifest(includeFilePath0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   484
        expected_paths0.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   485
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   486
        print expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   487
        assert content == expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   488
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   489
        content = self.__read_manifest(includeFilePath1)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   490
        expected_paths1.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   491
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   492
        print expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   493
        assert content == expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   494
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   495
        content = self.__read_manifest(includeFilePath9999)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   496
        expected_paths9999.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   497
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   498
        print expected_paths9999
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   499
        assert content == expected_paths9999
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   500
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   501
        assert os.path.exists(includeFilePathInternal) == False
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   502
        print "Commands : ", cmds
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   503
        assert len(cmds) == 1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   504
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   505
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   506
    def test_distribution_policy_mapper_remover_config(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   507
        """ Testing the policy remover mapper. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   508
        configDict = {'root.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   509
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   510
                  'archives.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   511
                  'name': 's60_policy_mapper_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   512
                  'include': 's60/',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   513
                  'policy.root.dir': os.path.join(root_test_dir, 's60'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   514
                  'archive.tool': '7za',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   515
                  'mapper': 'policy.remover',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   516
                  'policy.zip2zip': 'true',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   517
                  'policy.csv': os.path.join(os.environ['TEST_DATA'], 'data/distribution.policy.id_status.csv'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   518
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   519
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   520
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   521
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   522
        manifest_file_path = builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   523
        cmds = builder.manifest_to_commands(config, manifest_file_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   524
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   525
        expected_paths = ['s60' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   526
                           's60' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   527
                           's60' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   528
                           's60' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   529
                           's60' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   530
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   531
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt',                           
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   532
                           's60' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',                           
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   533
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'another_subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   534
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   535
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   536
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   537
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'another_subdir' + os.sep + 'to_be_removed_9999.txt',                           
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   538
                           's60' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   539
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   540
            for i in range(len(expected_paths)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   541
                expected_paths[i] = expected_paths[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   542
        expected_paths.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   543
        expected_paths0 = ['s60' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   544
                           's60' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   545
                           's60' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   546
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   547
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt',                           
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   548
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   549
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   550
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   551
            for i in range(len(expected_paths0)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   552
                expected_paths0[i] = expected_paths0[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   553
        expected_paths1 = ['s60' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   554
                           's60' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   555
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   556
            for i in range(len(expected_paths1)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   557
                expected_paths1[i] = expected_paths1[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   558
        expected_paths1.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   559
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   560
        includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   561
        includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   562
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   563
        content = self.__read_manifest(includeFilePath)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   564
        expected_paths.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   565
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   566
        print expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   567
        assert content == expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   568
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   569
        content = self.__read_manifest(includeFilePath0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   570
        expected_paths0.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   571
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   572
        print expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   573
        assert content == expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   574
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   575
        content = self.__read_manifest(includeFilePath1)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   576
        expected_paths1.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   577
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   578
        print expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   579
        assert content == expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   580
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   581
        print cmds        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   582
        assert len(cmds[3]) == 7
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   583
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   584
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   585
    def test_distribution_policy_mapper_sf_remover_config(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   586
        """ Testing the policy SFL remover mapper. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   587
        configDict = {'root.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   588
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   589
                  'archives.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   590
                  'name': 'sf_policy_sf_mapper_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   591
                  'include': 'sf/',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   592
                  'policy.root.dir': os.path.join(root_test_dir, 'sf'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   593
                  'archive.tool': '7za',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   594
                  'mapper': 'sfl.policy.remover',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   595
                  'policy.zip2zip': 'false',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   596
                  'policy.csv': os.path.join(os.environ['TEST_DATA'], 'data/distribution.policy.extended_for_sf.id_status.csv'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   597
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   598
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   599
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   600
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   601
        manifest_file_path = builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   602
        cmds = builder.manifest_to_commands(config, manifest_file_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   603
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   604
        expected_paths = ['sf' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   605
                           'sf' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   606
                           'sf' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   607
                           'sf' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   608
                           'sf' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   609
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   610
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt',                           
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   611
                           'sf' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   612
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'subdir_nofiles' + os.sep + 'subdir_nofiles2',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   613
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'subdir_nopolicy' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   614
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   615
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   616
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   617
                           'sf' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   618
                           'sf' + os.sep + 'component_sfl' + os.sep + 'component_sfl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   619
                           'sf' + os.sep + 'component_sfl' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   620
                           'sf' + os.sep + 'component_epl' + os.sep + 'component_epl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   621
                           'sf' + os.sep + 'component_epl' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   622
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   623
            for i in range(len(expected_paths)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   624
                expected_paths[i] = expected_paths[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   625
        expected_paths0 = ['sf' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   626
                           'sf' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   627
                           'sf' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   628
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   629
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   630
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   631
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   632
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   633
            for i in range(len(expected_paths0)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   634
                expected_paths0[i] = expected_paths0[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   635
        expected_paths1 = ['sf' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   636
                           'sf' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   637
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   638
            for i in range(len(expected_paths1)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   639
                expected_paths1[i] = expected_paths1[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   640
        expected_paths3 = ['sf' + os.sep + 'component_sfl' + os.sep + 'component_sfl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   641
                           'sf' + os.sep + 'component_sfl' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   642
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   643
            for i in range(len(expected_paths3)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   644
                expected_paths3[i] = expected_paths3[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   645
        expected_paths7 = ['sf' + os.sep + 'component_epl' + os.sep + 'component_epl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   646
                           'sf' + os.sep + 'component_epl' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   647
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   648
            for i in range(len(expected_paths7)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   649
                expected_paths7[i] = expected_paths7[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   650
        expected_paths9 = ['sf' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   651
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'subdir_nofiles' + os.sep + 'subdir_nofiles2',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   652
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'subdir_nopolicy' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   653
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   654
                           'sf' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   655
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   656
            for i in range(len(expected_paths9)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   657
                expected_paths9[i] = expected_paths9[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   658
 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   659
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_includefile.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   660
        includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_0.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   661
        includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_1.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   662
        includeFilePath3 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_3.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   663
        includeFilePath7 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_7.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   664
        includeFilePath9 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_9999.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   665
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   666
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   667
        content = self.__read_manifest(includeFilePath)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   668
        expected_paths.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   669
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   670
        print expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   671
        assert content == expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   672
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   673
        content = self.__read_manifest(includeFilePath0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   674
        expected_paths0.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   675
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   676
        print expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   677
        assert content == expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   678
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   679
        content = self.__read_manifest(includeFilePath1)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   680
        expected_paths1.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   681
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   682
        print expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   683
        assert content == expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   684
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   685
        content = self.__read_manifest(includeFilePath3)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   686
        expected_paths3.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   687
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   688
        print expected_paths3
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   689
        assert content == expected_paths3
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   690
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   691
        content = self.__read_manifest(includeFilePath7)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   692
        expected_paths7.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   693
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   694
        print expected_paths7
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   695
        assert content == expected_paths7
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   696
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   697
        content = self.__read_manifest(includeFilePath9)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   698
        expected_paths9.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   699
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   700
        print expected_paths9
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   701
        assert content == expected_paths9
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   702
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   703
        # checking the number of command generated
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   704
        assert len(cmds) == 2, "Must only have 2 steps in the archiving (archiving, removing)."
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   705
        assert len(cmds[0]) == 5, "Must only have 5 output files."
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   706
        print len(cmds[1])
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   707
        for cmd in cmds[1]:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   708
            print cmd
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   709
        assert len(cmds[1]) == len(expected_paths)-len(expected_paths3), "Remore must be equal to len(expected_paths) - len(expected_paths3)"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   710
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   711
    def test_distribution_policy_mapper_epl_remover_config(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   712
        """ Testing the policy EPL remover mapper. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   713
        configDict = {'root.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   714
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   715
                  'archives.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   716
                  'name': 'sf_policy_epl_mapper_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   717
                  'include': 'sf/',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   718
                  'policy.root.dir': os.path.join(root_test_dir, 'sf'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   719
                  'archive.tool': '7za',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   720
                  'mapper': 'epl.policy.remover',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   721
                  'policy.zip2zip': 'false',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   722
                  'policy.csv': os.path.join(os.environ['TEST_DATA'], 'data/distribution.policy.extended_for_sf.id_status.csv'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   723
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   724
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   725
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   726
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   727
        manifest_file_path = builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   728
        cmds = builder.manifest_to_commands(config, manifest_file_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   729
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   730
        expected_paths = ['sf' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   731
                           'sf' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   732
                           'sf' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   733
                           'sf' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   734
                           'sf' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   735
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   736
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   737
                           'sf' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   738
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'subdir_nofiles' + os.sep + 'subdir_nofiles2',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   739
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'subdir_nopolicy' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   740
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   741
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   742
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   743
                           'sf' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   744
                           'sf' + os.sep + 'component_sfl' + os.sep + 'component_sfl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   745
                           'sf' + os.sep + 'component_sfl' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   746
                           'sf' + os.sep + 'component_epl' + os.sep + 'component_epl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   747
                           'sf' + os.sep + 'component_epl' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   748
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   749
            for i in range(len(expected_paths)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   750
                expected_paths[i] = expected_paths[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   751
        expected_paths0 = ['sf' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   752
                           'sf' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   753
                           'sf' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   754
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   755
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   756
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   757
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   758
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   759
            for i in range(len(expected_paths0)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   760
                expected_paths0[i] = expected_paths0[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   761
        expected_paths1 = ['sf' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   762
                           'sf' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   763
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   764
            for i in range(len(expected_paths1)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   765
                expected_paths1[i] = expected_paths1[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   766
        expected_paths3 = ['sf' + os.sep + 'component_sfl' + os.sep + 'component_sfl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   767
                           'sf' + os.sep + 'component_sfl' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   768
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   769
            for i in range(len(expected_paths3)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   770
                expected_paths3[i] = expected_paths3[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   771
        expected_paths7 = ['sf' + os.sep + 'component_epl' + os.sep + 'component_epl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   772
                           'sf' + os.sep + 'component_epl' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   773
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   774
            for i in range(len(expected_paths7)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   775
                expected_paths7[i] = expected_paths7[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   776
        expected_paths9 = ['sf' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   777
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'subdir_nofiles' + os.sep + 'subdir_nofiles2',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   778
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'subdir_nopolicy' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   779
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   780
                           'sf' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   781
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   782
            for i in range(len(expected_paths9)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   783
                expected_paths9[i] = expected_paths9[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   784
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   785
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_includefile.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   786
        includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_0.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   787
        includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_1.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   788
        includeFilePath3 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_3.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   789
        includeFilePath7 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_7.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   790
        includeFilePath9 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_9999.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   791
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   792
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   793
        content = self.__read_manifest(includeFilePath)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   794
        expected_paths.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   795
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   796
        print expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   797
        assert content == expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   798
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   799
        content = self.__read_manifest(includeFilePath0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   800
        expected_paths0.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   801
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   802
        print expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   803
        assert content == expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   804
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   805
        content = self.__read_manifest(includeFilePath1)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   806
        expected_paths1.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   807
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   808
        print expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   809
        assert content == expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   810
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   811
        content = self.__read_manifest(includeFilePath3)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   812
        expected_paths3.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   813
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   814
        print expected_paths3
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   815
        assert content == expected_paths3
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   816
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   817
        content = self.__read_manifest(includeFilePath7)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   818
        expected_paths7.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   819
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   820
        print expected_paths7
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   821
        assert content == expected_paths7
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   822
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   823
        content = self.__read_manifest(includeFilePath9)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   824
        expected_paths9.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   825
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   826
        print expected_paths9
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   827
        assert content == expected_paths9
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   828
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   829
        # checking the number of command generated
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   830
        assert len(cmds) == 2, "Must only have 2 steps in the archiving (archiving, removing)."
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   831
        assert len(cmds[0]) == 5, "Must only have 5 output files."
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   832
        assert len(cmds[1]) == len(expected_paths)-len(expected_paths3), "Remore must be equal to len(expected_paths) - len(expected_paths3)"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   833
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   834
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   835
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   836
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   837
    def __read_manifest(self, manifest):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   838
        """ read the file and sort"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   839
        with open(manifest) as f:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   840
            content = f.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   841
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   842
            content = [s.strip().lower() for s in content]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   843
        else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   844
            content = [s.strip() for s in content]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   845
        content.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   846
        return content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   847
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   848
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   849
    def test_split_manifest_file(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   850
        """ A LogicalArchive can split a manifest correctly. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   851
        configDict = {'root.dir': os.path.abspath(root_test_dir),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   852
                  'temp.build.dir': os.path.abspath(os.path.join(root_test_dir, 'temp_build_files')),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   853
                  'archives.dir': os.path.abspath(root_test_dir),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   854
                  'name': 'manifest_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   855
                  'max.files.per.archive': '1',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   856
                  'include': 'dir/',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   857
                  'exclude': 'dir/emptysubdir3',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   858
                  'archive.tool': '7za'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   859
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   860
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   861
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   862
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   863
        manifest_file_path = builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   864
        builder.manifest_to_commands(config, manifest_file_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   865
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   866
        expectedPaths = ['dir' + os.sep + 'emptysubdir1','dir' + os.sep + 'emptysubdir2']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   867
        expectedPaths1 = ['dir' + os.sep + 'emptysubdir1\n']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   868
        expectedPaths2 = ['dir' + os.sep + 'emptysubdir2\n']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   869
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   870
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   871
        includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_part01.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   872
        includeFilePath2 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_part02.txt')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   873
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   874
        with open(includeFilePath) as f:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   875
            content = f.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   876
        with open(includeFilePath1) as f:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   877
            content1 = f.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   878
        with open(includeFilePath2) as f:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   879
            content2 = f.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   880
        print "content: ", content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   881
        print "content1: ", content1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   882
        print "content2: ", content2
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   883
        print "expectedPaths: ", expectedPaths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   884
        print "expectedPaths1: ", expectedPaths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   885
        print "expectedPaths2: ", expectedPaths2
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   886
        content = [s.strip().lower() for s in content]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   887
        self.assert_(content == expectedPaths)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   888
        self.assert_(content1 == expectedPaths1)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   889
        self.assert_(content2 == expectedPaths2)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   890
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   891
class CheckRootDirValueTest(unittest.TestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   892
    """test root drive value"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   893
    def test_checkRootDirValue(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   894
        """ Testing the root drive value. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   895
        configDict = {'root.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   896
                'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   897
                'archives.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   898
                'name': 'regular_path_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   899
                'include': 'dir1/*.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   900
                'archive.tool': '7za'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   901
               }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   902
        configDictUnc = {'root.dir': "\\\\server\\share\\dir",
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   903
                'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   904
                'archives.dir': root_test_dir,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   905
                'name': 'unc_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   906
                'include': 'dir1/*.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   907
                'archive.tool': '7za'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   908
               }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   909
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   910
        configUnc = configuration.Configuration(configDictUnc)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   911
        builder = MockedArchivePreBuilder(configuration.ConfigurationSet([config, configUnc]), "config", writerType='make', index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   912
        builder.rewriteXMLFile(os.path.join(os.environ['TEST_DATA'], 'data/zip_checkDrive_test.cfg.xml'), os.path.join(os.environ['TEST_DATA'], 'data/zip_checkDrive_test.cfg.xml.parsed'))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   913
        (build_drive, _) = os.path.splitdrive(os.path.normpath(tempfile.gettempdir()))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   914
        rootList = builder.checkRootDirValue(MockedConfigBuilder(), os.path.join(os.environ['TEST_DATA'], 'data/zip_checkDrive_test.cfg.xml.parsed'), build_drive, 'wvdo_sources')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   915
        assert rootList is not None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   916
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   917
            roots = builder.getCommonUncRoots(['\\\\server\\share\\dir', 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   918
                                               '\\\\server\\share', 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   919
                                               '\\\\server\\share1\\dir',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   920
                                               '\\\\server2\\share\\somedir'])
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   921
            self.assert_(len(roots) == 3)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   922
            self.assert_('\\\\server\\share\\' in roots)
618
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
   923
            self.assert_('\\\\server\\share1\\dir\\' in roots)
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
   924
            self.assert_('\\\\server2\\share\\somedir\\' in roots)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   925
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   926
class MockedConfigBuilder:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   927
    """."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   928
            
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   929
    def writeToXML(self, xml_file, configs, parse_xml_file):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   930
        """writeToXML"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   931
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   932
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   933
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   934
class MockedArchivePreBuilder(archive.ArchivePreBuilder):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   935
    """ ."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   936
    def substUncPath(self, _):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   937
        """ subst the unc path"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   938
        if os.sep != '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   939
            return None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   940
        return fileutils.get_next_free_drive()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   941
          
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   942
    def unSubStituteDrives(self, drive):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   943
        """ unsubstitute the drive"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   944
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   945
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   946
    def rewriteXMLFile(self, xml_file, parse_xml_file):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   947
        """re-write XML file"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   948
        doc = xml.dom.minidom.parse(xml_file)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   949
        out = open(parse_xml_file, 'w')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   950
        doc.writexml(out, indent='')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   951
        out.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   952
            
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   953
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   954
class ZipArchiverTest(unittest.TestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   955
    """ Unit test case for seven zip archiver """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   956
    def test_extension(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   957
        t = archive.tools.SevenZipArchiver()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   958
        self.assert_(t.extension() == ".zip")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   959
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   960
class SevenZipFormatArchiverTest(unittest.TestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   961
    """ Testing 7z archiver class """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   962
    def test_archive(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   963
        """ Testing whether the ant file for running 7z is created """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   964
        configDict = {'root.dir': os.path.abspath(root_test_dir),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   965
                  'temp.build.dir': os.path.abspath(os.path.join(root_test_dir, 'temp_build_files')),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   966
                  'archives.dir': os.path.abspath(root_test_dir),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   967
                  'name': 'manifest_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   968
                  'max.files.per.archive': '1',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   969
                  'include': 'dir/',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   970
                  'exclude': 'dir/emptysubdir3',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   971
                  'archive.tool': '7z'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   972
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   973
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   974
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   975
        manifest_file_path = builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   976
        builder.manifest_to_commands(config, manifest_file_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   977
        tmpfilename = os.path.join(os.path.abspath(root_test_dir),'test_archive_7z.xml')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   978
        builder.write(tmpfilename)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   979
        tmpfileh = open(tmpfilename,'r')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   980
        content = tmpfileh.read()    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   981
        assert content.find('executable="7z">') != -1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   982
        assert content.find('<arg line="a -mx9') != -1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   983
        tmpfileh.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   984
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   985
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   986
#class ZipArchiverTest(unittest.TestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   987
#    def setUp(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   988
#        archiveConfig = amara.parse(open(os.environ['TEST_DATA'] + '/data/zip_archive_test.cfg.xml'))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   989
#        self.archivePreBuilder = archive.ArchivePreBuilder(archiveConfig)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   990
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   991
#    def testZipArchiverCommand(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   992
#        """Zip archiver creates correct command."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   993
#        archiver = archive.ZipArchiver(self.archivePreBuilder)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   994
#        archiver._start_archive('foo')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   995
#        archiver.end_archive()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   996
#        commands = archiver.commandList.allCommands()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   997
#        assert len(commands) == 1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   998
#        command = commands[0]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   999
#        assert command.executable() == 'zip.exe'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1000
#        assert command.cmd() == '-R . c:\\temp\\foo.zip'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1001
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1002
#    def testZipArchiverOperation(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1003
#        """Zip archiver runs zip operation correctly."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1004
#        buildFilePath = self.archivePreBuilder.createArchiveBuildFile('zip_exec.ant.xml')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1005
#        result = run(r'ant -f c:\temp\output\temp_build_files\zip_exec.ant.xml all -Dnumber.of.threads=1')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1006
#        print result
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1007
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1008
def run( command ):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1009
    """ run the code"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1010
    #print "Run command: " + command
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1011
    ( _, stdout ) = os.popen4( command )
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1012
    result = stdout.read()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1013
    return result
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1014
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1015
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1016
if __name__ == "__main__":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1017
    unittest.main()