buildframework/helium/sf/python/pythoncore/lib/pythoncorecpythontests/test_archive.py
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 588 c7c26511138f
child 645 b8d81fa19e7d
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
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
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    33
import pythoncorecpythontests.test_fileutils
587
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
    
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    38
root_test_dir = pythoncorecpythontests.test_fileutils.root_test_dir
587
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. """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    42
    pythoncorecpythontests.test_fileutils.setup_module()
587
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. """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    46
    pythoncorecpythontests.test_fileutils.teardown_module()
587
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)
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    58
        buildFilePath = os.path.join(root_test_dir, r'archive_test.ant.xml')
587
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. """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    83
        configDict = {'root.dir': root_test_dir,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    84
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    85
                  'archives.dir': root_test_dir,
587
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
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    97
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt')
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    99
        with open(includeFilePath) as f_file:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   100
            content = f_file.readlines()
587
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. """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   108
        configDict = {'root.dir': root_test_dir,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   109
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   110
                  'archives.dir': root_test_dir,
587
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
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   122
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt')
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   123
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   124
        with open(includeFilePath) as f_file:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   125
            content = f_file.readlines()
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   126
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   127
        print expectedPaths
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   128
        content = [s_1.strip().lower() for s_1 in content]
587
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. """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   133
        excludelst = os.path.join(root_test_dir, 'exclude.lst')
587
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")
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   137
        flh.write(os.path.join(root_test_dir, 'dir1', 'file1.txt') + "\n")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   138
        flh.write(os.path.join(root_test_dir, 'dir1/subdir1/subdir1_file.txt') + "\n")
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   139
        flh.close()
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   140
        configDict = {'root.dir': root_test_dir,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   141
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   142
                  'archives.dir': root_test_dir,
587
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
        
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   160
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt')
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   161
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   162
        with open(includeFilePath) as f_file:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   163
            content = f_file.readlines()
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   164
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   165
        print expectedPaths
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   166
        content = [s_1.strip().lower() for s_1 in content]
587
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
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   170
    def test_manifestfiles_wth_xcld_lst_abs_ndrv(self):
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   171
        """ A LogicalArchive can create a correct manifest with external list and drive. """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   172
        rtd = os.path.splitdrive(os.path.abspath(root_test_dir))[1]
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   173
        excludelst = os.path.join(root_test_dir, 'exclude.lst')
587
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()
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   180
        configDict = {'root.dir': os.path.abspath(root_test_dir),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   181
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   182
                  'archives.dir': root_test_dir,
587
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
        
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   200
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt')
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   201
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   202
        with open(includeFilePath) as f_file:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   203
            content = f_file.readlines()
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   204
        if os.sep == '\\':
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   205
            content = [s_1.strip().lower() for s_1 in content]
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   206
        else:
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   207
            content = [s_1.strip() for s_1 in content]
587
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
        """ . """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   246
        configDict = {'root.dir': root_test_dir,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   247
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   248
                  'archives.dir': root_test_dir,
587
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)
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   259
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_test_includefile.txt')
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   260
        
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   261
        with open(includeFilePath) as f_file:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   262
            content = f_file.readlines()
587
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. """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   280
        configDict = {'root.dir': os.path.abspath(root_test_dir),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   281
                  'temp.build.dir': os.path.abspath(os.path.join(root_test_dir, 'temp_build_files')),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   282
                  'archives.dir': os.path.abspath(root_test_dir),
587
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)
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   291
        manifest_file_path = builder.build_manifest(config)
587
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
        
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   294
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_includefile.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   295
        includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_part01.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   296
        includeFilePath2 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_part02.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   297
        includeFilePath3 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_unicode_part03.txt')
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   298
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   299
        with open(includeFilePath) as f_file:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   300
            content = f_file.readlines()
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   301
        with open(includeFilePath1) as f_file:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   302
            content1 = f_file.readlines()
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   303
        with open(includeFilePath2) as f_file:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   304
            content2 = f_file.readlines()
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   305
        with open(includeFilePath3) as f_file:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   306
            content3 = f_file.readlines()
587
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. """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   319
        configDict = {'root.dir': root_test_dir,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   320
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   321
                  'archives.dir': root_test_dir,
587
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()
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   375
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   376
        includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   377
        includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   378
        includeFilePath9999 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_9999.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   379
        includeFilePathInternal = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test.internal.txt')
587
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
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   411
# pylint: disable=C0103
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   412
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   413
    def test_distribution_policy_mapper_config_no_zip2zip(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   414
        """ Testing the policy mapper. """
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   415
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   416
        configDict = {'root.dir': root_test_dir,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   417
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   418
                  'archives.dir': root_test_dir,
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   419
                  'name': 's60_policy_mapper_test_noz2z',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   420
                  'include': 's60/',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   421
                  'archive.tool': '7za',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   422
                  'policy.zip2zip': 'false',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   423
                  'mapper': 'policy'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   424
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   425
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   426
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   427
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   428
        manifest_file_path = builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   429
        cmds = builder.manifest_to_commands(config, manifest_file_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   430
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   431
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   432
        expected_paths = ['s60' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   433
                           's60' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   434
                           's60' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   435
                           's60' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   436
                           's60' + os.sep + 'Distribution.Policy.S60',
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   437
                           '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
   438
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   439
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   440
                           's60' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   441
                           '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
   442
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   443
                           '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
   444
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   445
                           's60' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   446
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   447
            for i in range(len(expected_paths)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   448
                expected_paths[i] = expected_paths[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   449
        expected_paths0 = ['s60' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   450
                           's60' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   451
                           's60' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   452
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   453
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   454
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   455
                           '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
   456
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   457
            for i in range(len(expected_paths0)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   458
                expected_paths0[i] = expected_paths0[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   459
        expected_paths1 = ['s60' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   460
                           's60' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   461
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   462
            for i in range(len(expected_paths1)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   463
                expected_paths1[i] = expected_paths1[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   464
        expected_paths9999 = ['s60' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   465
                              '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
   466
                              's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   467
                              '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
   468
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   469
            for i in range(len(expected_paths9999)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   470
                expected_paths9999[i] = expected_paths9999[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   471
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   472
        expected_paths.sort()
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   473
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   474
        includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   475
        includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   476
        includeFilePath9999 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_9999.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   477
        includeFilePathInternal = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_noz2z.internal.txt')
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   478
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   479
        content = self.__read_manifest(includeFilePath)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   480
        expected_paths.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   481
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   482
        print expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   483
        assert content == expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   484
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   485
        content = self.__read_manifest(includeFilePath0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   486
        expected_paths0.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   487
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   488
        print expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   489
        assert content == expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   490
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   491
        content = self.__read_manifest(includeFilePath1)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   492
        expected_paths1.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   493
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   494
        print expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   495
        assert content == expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   496
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   497
        content = self.__read_manifest(includeFilePath9999)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   498
        expected_paths9999.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   499
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   500
        print expected_paths9999
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   501
        assert content == expected_paths9999
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   502
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   503
        assert os.path.exists(includeFilePathInternal) == False
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   504
        print "Commands : ", cmds
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   505
        assert len(cmds) == 1
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   506
# pylint: enable-msg=C0103
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   507
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   508
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   509
    def test_dist_policy_mapper_remover_config(self):
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   510
        """ Testing the policy remover mapper. """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   511
        configDict = {'root.dir': root_test_dir,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   512
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   513
                  'archives.dir': root_test_dir,
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   514
                  'name': 's60_policy_mapper_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   515
                  'include': 's60/',
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   516
                  'policy.root.dir': os.path.join(root_test_dir, 's60'),
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   517
                  'archive.tool': '7za',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   518
                  'mapper': 'policy.remover',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   519
                  'policy.zip2zip': 'true',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   520
                  'policy.csv': os.path.join(os.environ['TEST_DATA'], 'data/distribution.policy.id_status.csv'),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   521
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   522
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   523
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   524
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   525
        manifest_file_path = builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   526
        cmds = builder.manifest_to_commands(config, manifest_file_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   527
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   528
        expected_paths = ['s60' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   529
                           's60' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   530
                           's60' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   531
                           's60' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   532
                           's60' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   533
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   534
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt',                           
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   535
                           's60' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',                           
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   536
                           '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
   537
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   538
                           '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
   539
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   540
                           '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
   541
                           's60' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   542
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   543
            for i in range(len(expected_paths)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   544
                expected_paths[i] = expected_paths[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   545
        expected_paths.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   546
        expected_paths0 = ['s60' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   547
                           's60' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   548
                           's60' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   549
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   550
                           's60' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'not_to_be_removed_0.txt',                           
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   551
                           's60' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   552
                           '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
   553
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   554
            for i in range(len(expected_paths0)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   555
                expected_paths0[i] = expected_paths0[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   556
        expected_paths1 = ['s60' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   557
                           's60' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   558
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   559
            for i in range(len(expected_paths1)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   560
                expected_paths1[i] = expected_paths1[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   561
        expected_paths1.sort()
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   562
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_includefile.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   563
        includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_0.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   564
        includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/s60_policy_mapper_test_1.txt')
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   565
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   566
        content = self.__read_manifest(includeFilePath)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   567
        expected_paths.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   568
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   569
        print expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   570
        assert content == expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   571
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   572
        content = self.__read_manifest(includeFilePath0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   573
        expected_paths0.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   574
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   575
        print expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   576
        assert content == expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   577
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   578
        content = self.__read_manifest(includeFilePath1)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   579
        expected_paths1.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   580
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   581
        print expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   582
        assert content == expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   583
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   584
        print cmds        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   585
        assert len(cmds[3]) == 7
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   586
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   587
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   588
    def test_dist_policy_mapper_sf_remvr_config(self):
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   589
        """ Testing the policy SFL remover mapper. """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   590
        configDict = {'root.dir': root_test_dir,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   591
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   592
                  'archives.dir': root_test_dir,
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   593
                  'name': 'sf_policy_sf_mapper_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   594
                  'include': 'sf/',
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   595
                  'policy.root.dir': os.path.join(root_test_dir, 'sf'),
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   596
                  'archive.tool': '7za',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   597
                  'mapper': 'sfl.policy.remover',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   598
                  'policy.zip2zip': 'false',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   599
                  '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
   600
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   601
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   602
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   603
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   604
        manifest_file_path = builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   605
        cmds = builder.manifest_to_commands(config, manifest_file_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   606
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   607
        expected_paths = ['sf' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   608
                           'sf' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   609
                           'sf' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   610
                           'sf' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   611
                           'sf' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   612
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   613
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt',                           
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   614
                           'sf' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   615
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'subdir_nofiles' + os.sep + 'subdir_nofiles2',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   616
                           '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
   617
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   618
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   619
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   620
                           'sf' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   621
                           'sf' + os.sep + 'component_sfl' + os.sep + 'component_sfl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   622
                           'sf' + os.sep + 'component_sfl' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   623
                           'sf' + os.sep + 'component_epl' + os.sep + 'component_epl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   624
                           'sf' + os.sep + 'component_epl' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   625
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   626
            for i in range(len(expected_paths)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   627
                expected_paths[i] = expected_paths[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   628
        expected_paths0 = ['sf' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   629
                           'sf' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   630
                           'sf' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   631
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   632
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   633
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   634
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   635
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   636
            for i in range(len(expected_paths0)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   637
                expected_paths0[i] = expected_paths0[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   638
        expected_paths1 = ['sf' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   639
                           'sf' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   640
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   641
            for i in range(len(expected_paths1)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   642
                expected_paths1[i] = expected_paths1[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   643
        expected_paths3 = ['sf' + os.sep + 'component_sfl' + os.sep + 'component_sfl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   644
                           'sf' + os.sep + 'component_sfl' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   645
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   646
            for i in range(len(expected_paths3)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   647
                expected_paths3[i] = expected_paths3[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   648
        expected_paths7 = ['sf' + os.sep + 'component_epl' + os.sep + 'component_epl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   649
                           'sf' + os.sep + 'component_epl' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   650
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   651
            for i in range(len(expected_paths7)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   652
                expected_paths7[i] = expected_paths7[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   653
        expected_paths9 = ['sf' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   654
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'subdir_nofiles' + os.sep + 'subdir_nofiles2',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   655
                           '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
   656
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   657
                           'sf' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   658
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   659
            for i in range(len(expected_paths9)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   660
                expected_paths9[i] = expected_paths9[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   661
 
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   662
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_includefile.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   663
        includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_0.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   664
        includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_1.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   665
        includeFilePath3 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_3.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   666
        includeFilePath7 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_7.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   667
        includeFilePath9 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_sf_mapper_test_9999.txt')
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   668
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   669
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   670
        content = self.__read_manifest(includeFilePath)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   671
        expected_paths.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   672
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   673
        print expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   674
        assert content == expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   675
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   676
        content = self.__read_manifest(includeFilePath0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   677
        expected_paths0.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   678
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   679
        print expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   680
        assert content == expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   681
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   682
        content = self.__read_manifest(includeFilePath1)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   683
        expected_paths1.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   684
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   685
        print expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   686
        assert content == expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   687
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   688
        content = self.__read_manifest(includeFilePath3)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   689
        expected_paths3.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   690
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   691
        print expected_paths3
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   692
        assert content == expected_paths3
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   693
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   694
        content = self.__read_manifest(includeFilePath7)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   695
        expected_paths7.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   696
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   697
        print expected_paths7
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   698
        assert content == expected_paths7
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   699
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   700
        content = self.__read_manifest(includeFilePath9)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   701
        expected_paths9.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   702
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   703
        print expected_paths9
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   704
        assert content == expected_paths9
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   705
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   706
        # checking the number of command generated
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   707
        assert len(cmds) == 2, "Must only have 2 steps in the archiving (archiving, removing)."
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   708
        assert len(cmds[0]) == 5, "Must only have 5 output files."
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   709
        print len(cmds[1])
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   710
        for cmd in cmds[1]:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   711
            print cmd
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   712
        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
   713
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   714
    def test_dist_policy_mapper_epl_remvr_config(self):
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   715
        """ Testing the policy EPL remover mapper. """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   716
        configDict = {'root.dir': root_test_dir,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   717
                  'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   718
                  'archives.dir': root_test_dir,
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   719
                  'name': 'sf_policy_epl_mapper_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   720
                  'include': 'sf/',
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   721
                  'policy.root.dir': os.path.join(root_test_dir, 'sf'),
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   722
                  'archive.tool': '7za',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   723
                  'mapper': 'epl.policy.remover',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   724
                  'policy.zip2zip': 'false',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   725
                  '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
   726
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   727
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   728
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   729
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   730
        manifest_file_path = builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   731
        cmds = builder.manifest_to_commands(config, manifest_file_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   732
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   733
        expected_paths = ['sf' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   734
                           'sf' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   735
                           'sf' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   736
                           'sf' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   737
                           'sf' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   738
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   739
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   740
                           'sf' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   741
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'subdir_nofiles' + os.sep + 'subdir_nofiles2',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   742
                           '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
   743
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   744
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   745
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   746
                           'sf' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   747
                           'sf' + os.sep + 'component_sfl' + os.sep + 'component_sfl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   748
                           'sf' + os.sep + 'component_sfl' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   749
                           'sf' + os.sep + 'component_epl' + os.sep + 'component_epl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   750
                           'sf' + os.sep + 'component_epl' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   751
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   752
            for i in range(len(expected_paths)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   753
                expected_paths[i] = expected_paths[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   754
        expected_paths0 = ['sf' + os.sep + 'component_public' + os.sep + 'component_public_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   755
                           'sf' + os.sep + 'component_public' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   756
                           'sf' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   757
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   758
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   759
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'Distribution.Policy.S60',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   760
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'subdir' + os.sep + 'to_be_removed_9999.txt',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   761
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   762
            for i in range(len(expected_paths0)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   763
                expected_paths0[i] = expected_paths0[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   764
        expected_paths1 = ['sf' + os.sep + 'component_private' + os.sep + 'component_private_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   765
                           'sf' + os.sep + 'component_private' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   766
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   767
            for i in range(len(expected_paths1)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   768
                expected_paths1[i] = expected_paths1[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   769
        expected_paths3 = ['sf' + os.sep + 'component_sfl' + os.sep + 'component_sfl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   770
                           'sf' + os.sep + 'component_sfl' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   771
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   772
            for i in range(len(expected_paths3)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   773
                expected_paths3[i] = expected_paths3[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   774
        expected_paths7 = ['sf' + os.sep + 'component_epl' + os.sep + 'component_epl_file.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   775
                           'sf' + os.sep + 'component_epl' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   776
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   777
            for i in range(len(expected_paths7)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   778
                expected_paths7[i] = expected_paths7[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   779
        expected_paths9 = ['sf' + os.sep + 'missing' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   780
                           'sf' + os.sep + 'missing' + os.sep + 'subdir' + os.sep + 'subdir_nofiles' + os.sep + 'subdir_nofiles2',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   781
                           '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
   782
                           'sf' + os.sep + 'UPPERCASE_MISSING' + os.sep + 'to_be_removed_9999.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   783
                           'sf' + os.sep + 'not_in_cvs' + os.sep + 'Distribution.Policy.S60',]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   784
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   785
            for i in range(len(expected_paths9)):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   786
                expected_paths9[i] = expected_paths9[i].lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   787
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   788
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_includefile.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   789
        includeFilePath0 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_0.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   790
        includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_1.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   791
        includeFilePath3 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_3.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   792
        includeFilePath7 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_7.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   793
        includeFilePath9 = os.path.join(root_test_dir, 'temp_build_files/sf_policy_epl_mapper_test_9999.txt')
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   794
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   795
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   796
        content = self.__read_manifest(includeFilePath)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   797
        expected_paths.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   798
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   799
        print expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   800
        assert content == expected_paths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   801
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   802
        content = self.__read_manifest(includeFilePath0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   803
        expected_paths0.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   804
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   805
        print expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   806
        assert content == expected_paths0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   807
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   808
        content = self.__read_manifest(includeFilePath1)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   809
        expected_paths1.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   810
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   811
        print expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   812
        assert content == expected_paths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   813
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   814
        content = self.__read_manifest(includeFilePath3)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   815
        expected_paths3.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   816
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   817
        print expected_paths3
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   818
        assert content == expected_paths3
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   819
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   820
        content = self.__read_manifest(includeFilePath7)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   821
        expected_paths7.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   822
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   823
        print expected_paths7
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   824
        assert content == expected_paths7
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   825
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   826
        content = self.__read_manifest(includeFilePath9)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   827
        expected_paths9.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   828
        print content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   829
        print expected_paths9
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   830
        assert content == expected_paths9
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   831
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   832
        # checking the number of command generated
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   833
        assert len(cmds) == 2, "Must only have 2 steps in the archiving (archiving, removing)."
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   834
        assert len(cmds[0]) == 5, "Must only have 5 output files."
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   835
        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
   836
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   837
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   838
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   839
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   840
    def __read_manifest(self, manifest):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   841
        """ read the file and sort"""
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   842
        with open(manifest) as f_file:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   843
            content = f_file.readlines()
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   844
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   845
            content = [s.strip().lower() for s in content]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   846
        else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   847
            content = [s.strip() for s in content]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   848
        content.sort()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   849
        return content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   850
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   851
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   852
    def test_split_manifest_file(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   853
        """ A LogicalArchive can split a manifest correctly. """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   854
        configDict = {'root.dir': os.path.abspath(root_test_dir),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   855
                  'temp.build.dir': os.path.abspath(os.path.join(root_test_dir, 'temp_build_files')),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   856
                  'archives.dir': os.path.abspath(root_test_dir),
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   857
                  'name': 'manifest_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   858
                  'max.files.per.archive': '1',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   859
                  'include': 'dir/',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   860
                  'exclude': 'dir/emptysubdir3',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   861
                  'archive.tool': '7za'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   862
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   863
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   864
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   865
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   866
        manifest_file_path = builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   867
        builder.manifest_to_commands(config, manifest_file_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   868
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   869
        expectedPaths = ['dir' + os.sep + 'emptysubdir1','dir' + os.sep + 'emptysubdir2']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   870
        expectedPaths1 = ['dir' + os.sep + 'emptysubdir1\n']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   871
        expectedPaths2 = ['dir' + os.sep + 'emptysubdir2\n']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   872
        
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   873
        includeFilePath = os.path.join(root_test_dir, 'temp_build_files/manifest_test_includefile.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   874
        includeFilePath1 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_part01.txt')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   875
        includeFilePath2 = os.path.join(root_test_dir, 'temp_build_files/manifest_test_part02.txt')
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   876
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   877
        with open(includeFilePath) as f_file:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   878
            content = f_file.readlines()
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   879
        with open(includeFilePath1) as f_file:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   880
            content1 = f_file.readlines()
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   881
        with open(includeFilePath2) as f_file:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   882
            content2 = f_file.readlines()
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   883
        print "content: ", content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   884
        print "content1: ", content1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   885
        print "content2: ", content2
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   886
        print "expectedPaths: ", expectedPaths
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   887
        print "expectedPaths1: ", expectedPaths1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   888
        print "expectedPaths2: ", expectedPaths2
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   889
        content = [s.strip().lower() for s in content]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   890
        self.assert_(content == expectedPaths)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   891
        self.assert_(content1 == expectedPaths1)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   892
        self.assert_(content2 == expectedPaths2)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   893
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   894
class CheckRootDirValueTest(unittest.TestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   895
    """test root drive value"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   896
    def test_checkRootDirValue(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   897
        """ Testing the root drive value. """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   898
        configDict = {'root.dir': root_test_dir,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   899
                'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   900
                'archives.dir': root_test_dir,
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   901
                'name': 'regular_path_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   902
                'include': 'dir1/*.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   903
                'archive.tool': '7za'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   904
               }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   905
        configDictUnc = {'root.dir': "\\\\server\\share\\dir",
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   906
                'temp.build.dir': os.path.join(root_test_dir, 'temp_build_files'),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   907
                'archives.dir': root_test_dir,
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   908
                'name': 'unc_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   909
                'include': 'dir1/*.txt',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   910
                'archive.tool': '7za'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   911
               }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   912
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   913
        configUnc = configuration.Configuration(configDictUnc)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   914
        builder = MockedArchivePreBuilder(configuration.ConfigurationSet([config, configUnc]), "config", writerType='make', index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   915
        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
   916
        (build_drive, _) = os.path.splitdrive(os.path.normpath(tempfile.gettempdir()))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   917
        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
   918
        assert rootList is not None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   919
        if os.sep == '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   920
            roots = builder.getCommonUncRoots(['\\\\server\\share\\dir', 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   921
                                               '\\\\server\\share', 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   922
                                               '\\\\server\\share1\\dir',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   923
                                               '\\\\server2\\share\\somedir'])
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   924
            self.assert_(len(roots) == 3)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   925
            self.assert_('\\\\server\\share\\' in roots)
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   926
            self.assert_('\\\\server\\share1\\dir\\' in roots)
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   927
            self.assert_('\\\\server2\\share\\somedir\\' in roots)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   928
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   929
class MockedConfigBuilder(object):
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   930
    """."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   931
            
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   932
    def writeToXML(self, xml_file, configs, parse_xml_file):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   933
        """writeToXML"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   934
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   935
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   936
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   937
class MockedArchivePreBuilder(archive.ArchivePreBuilder):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   938
    """ ."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   939
    def substUncPath(self, _):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   940
        """ subst the unc path"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   941
        if os.sep != '\\':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   942
            return None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   943
        return fileutils.get_next_free_drive()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   944
          
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   945
    def unSubStituteDrives(self, drive):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   946
        """ unsubstitute the drive"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   947
        pass
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   948
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   949
    def rewriteXMLFile(self, xml_file, parse_xml_file):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   950
        """re-write XML file"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   951
        doc = xml.dom.minidom.parse(xml_file)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   952
        out = open(parse_xml_file, 'w')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   953
        doc.writexml(out, indent='')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   954
        out.close()
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   955
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   956
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   957
class ZipArchiverTest(unittest.TestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   958
    """ Unit test case for seven zip archiver """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   959
    def test_extension(self):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   960
        """test extension"""
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   961
        t_tools = archive.tools.SevenZipArchiver()
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   962
        self.assert_(t_tools.extension() == ".zip")
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   963
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   964
class SevenZipFormatArchiverTest(unittest.TestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   965
    """ Testing 7z archiver class """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   966
    def test_archive(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   967
        """ Testing whether the ant file for running 7z is created """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   968
        configDict = {'root.dir': os.path.abspath(root_test_dir),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   969
                  'temp.build.dir': os.path.abspath(os.path.join(root_test_dir, 'temp_build_files')),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   970
                  'archives.dir': os.path.abspath(root_test_dir),
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   971
                  'name': 'manifest_test',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   972
                  'max.files.per.archive': '1',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   973
                  'include': 'dir/',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   974
                  'exclude': 'dir/emptysubdir3',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   975
                  'archive.tool': '7z'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   976
                 }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   977
        config = configuration.Configuration(configDict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   978
        builder = archive.ArchivePreBuilder(configuration.ConfigurationSet([config]), "config", index=0)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   979
        manifest_file_path = builder.build_manifest(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   980
        builder.manifest_to_commands(config, manifest_file_path)
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   981
        tmpfilename = os.path.join(os.path.abspath(root_test_dir),'test_archive_7z.xml')
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   982
        builder.write(tmpfilename)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   983
        tmpfileh = open(tmpfilename,'r')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   984
        content = tmpfileh.read()    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   985
        assert content.find('executable="7z">') != -1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   986
        assert content.find('<arg line="a -mx9') != -1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   987
        tmpfileh.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   988
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   989
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   990
#class ZipArchiverTest(unittest.TestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   991
#    def setUp(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   992
#        archiveConfig = amara.parse(open(os.environ['TEST_DATA'] + '/data/zip_archive_test.cfg.xml'))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   993
#        self.archivePreBuilder = archive.ArchivePreBuilder(archiveConfig)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   994
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   995
#    def testZipArchiverCommand(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   996
#        """Zip archiver creates correct command."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   997
#        archiver = archive.ZipArchiver(self.archivePreBuilder)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   998
#        archiver._start_archive('foo')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   999
#        archiver.end_archive()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1000
#        commands = archiver.commandList.allCommands()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1001
#        assert len(commands) == 1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1002
#        command = commands[0]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1003
#        assert command.executable() == 'zip.exe'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1004
#        assert command.cmd() == '-R . c:\\temp\\foo.zip'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1005
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1006
#    def testZipArchiverOperation(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1007
#        """Zip archiver runs zip operation correctly."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1008
#        buildFilePath = self.archivePreBuilder.createArchiveBuildFile('zip_exec.ant.xml')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1009
#        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
  1010
#        print result
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1011
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1012
def run( command ):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1013
    """ run the code"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1014
    #print "Run command: " + command
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1015
    ( _, stdout ) = os.popen4( command )
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1016
    result = stdout.read()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1017
    return result
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1018
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1019
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1020
if __name__ == "__main__":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
  1021
    unittest.main()