configurationengine/source/scripts/tests/unittest_compare.py
author m2lahtel
Tue, 10 Aug 2010 14:29:28 +0300
changeset 3 e7e0ae78773e
parent 0 2e8eeb919028
permissions -rw-r--r--
ConE 1.2.11 release
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     1
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     2
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     3
# All rights reserved.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     4
# This component and the accompanying materials are made available
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     5
# under the terms of "Eclipse Public License v1.0"
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     6
# which accompanies this distribution, and is available
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     8
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     9
# Initial Contributors:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    11
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    12
# Contributors:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    13
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    14
# Description: 
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    15
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    16
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    17
"""
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    18
Test the configuration
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    19
"""
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    20
import unittest
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    21
import string
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    22
import sys
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    23
import os
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    24
import shutil
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    25
import subprocess
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    26
import difflib
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    27
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    28
from testautomation.base_testcase import BaseTestCase
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    29
from scripttest_common import get_cmd
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    30
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    31
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    32
ROOT_PATH       = os.path.dirname(os.path.abspath(__file__))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    33
TESTDATA_DIR    = os.path.normpath(os.path.join(ROOT_PATH, 'testdata/compare'))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    34
TEMP_DIR        = os.path.normpath(os.path.join(ROOT_PATH, 'temp/compare'))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    36
from cone.public import api
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    37
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    38
#import conesub_compare
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    39
class TestCompareAction(BaseTestCase):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    40
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    41
    def setUp(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    42
        if not os.path.exists(TEMP_DIR):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    43
            os.makedirs(TEMP_DIR)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    44
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    45
    #def test_parse_target_configuration(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    46
    #    act = conesub_compare.CompareAction('','','')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    47
    #    self.assertEquals(act.parse_target_configuration("root.confml"), ('','root.confml'))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    48
    #    self.assertEquals(act.parse_target_configuration("x:\foo.cpf;root.confml"), ('x:\foo.cpf','root.confml'))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    49
    #    self.assertEquals(act.parse_target_configuration("root\project;root.confml"), ('root\project','root.confml'))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    50
    #    self.assertEquals(act.parse_target_configuration("http://testserver:8000/external;foo/bar/root.confml"), ('http://testserver:8000/external','foo/bar/root.confml'))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    51
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    52
    def test_default_compare(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    53
        # Test comparison using default parameters
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    54
        orig_workdir = os.getcwd()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    55
        os.chdir(os.path.join(TEMP_DIR))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    56
        try:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    57
            project = os.path.join(TESTDATA_DIR, "project1.zip")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    58
            source_conf = "root1.confml"
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    59
            target_conf = "root2.confml"
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    60
            
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    61
            report_file = os.path.join(TEMP_DIR, "data_comparison.html")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    62
            self.remove_if_exists(report_file)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    63
            
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    64
            command = '%s -p "%s" -s "%s" -t "%s"' \
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    65
                % (get_cmd('compare'), project, source_conf, target_conf)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    66
            self.run_command(command)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    67
            self.assert_exists_and_contains_something(report_file)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    68
        finally:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    69
            os.chdir(orig_workdir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    70
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    71
    def test_compare_api_same_root(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    72
        self._run_comparison_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    73
            source_project  = 'project1.zip',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    74
            source_conf     = 'root1.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    75
            target_project  = None,
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    76
            target_conf     = 'root1.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    77
            template        = 'api_template.txt',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    78
            report_file     = 'api_p1r1_vs_p1r1.txt',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    79
            check_against_expected_output = True)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    80
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    81
    def test_compare_data_same_root(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    82
        self._run_comparison_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    83
            source_project  = 'project1.zip',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    84
            source_conf     = 'root1.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    85
            target_project  = None,
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    86
            target_conf     = 'root1.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    87
            template        = 'data_template.txt',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    88
            report_file     = 'data_p1r1_vs_p1r1.txt',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    89
            check_against_expected_output = True)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    90
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    91
    def test_compare_api_same_project_different_root(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    92
        self._run_comparison_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    93
            source_project  = 'project1.zip',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    94
            source_conf     = 'root1.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    95
            target_project  = None,
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    96
            target_conf     = 'root4.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    97
            template        = 'api_template.txt',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    98
            report_file     = 'api_p1r1_vs_p1r4.txt',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    99
            check_against_expected_output = True)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   100
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   101
    def test_compare_data_same_project_different_root(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   102
        self._run_comparison_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   103
            source_project  = 'project1.zip',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   104
            source_conf     = 'root1.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   105
            target_project  = None,
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   106
            target_conf     = 'root4.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   107
            template        = 'data_template.txt',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   108
            report_file     = 'data_p1r1_vs_p1r4.txt',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   109
            check_against_expected_output = True)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   110
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   111
    def test_compare_api_proj1_vs_proj2(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   112
        self._run_comparison_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   113
            source_project  = 'project1.zip',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   114
            source_conf     = 'root1.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   115
            target_project  = 'project2.zip',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   116
            target_conf     = 'root1.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   117
            template        = 'api_template.txt',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   118
            report_file     = 'api_p1r1_vs_p2r1.txt',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   119
            check_against_expected_output = True)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   120
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   121
    def test_compare_data_proj1_vs_proj2(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   122
        self._run_comparison_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   123
            source_project  = 'project1.zip',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   124
            source_conf     = 'root1.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   125
            target_project  = 'project2.zip',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   126
            target_conf     = 'root1.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   127
            template        = 'data_template.txt',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   128
            report_file     = 'data_p1r1_vs_p2r1.txt',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   129
            check_against_expected_output = True)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   130
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   131
    def test_comparison_using_type_api(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   132
        self._run_comparison_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   133
            source_project  = 'project1.zip',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   134
            source_conf     = 'root1.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   135
            target_project  = None,
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   136
            target_conf     = 'root4.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   137
            report_type     = 'api',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   138
            report_file     = 'api_p1r1_vs_p1r4.html',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   139
            check_against_expected_output = False)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   140
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   141
    def test_comparison_using_type_data(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   142
        self._run_comparison_test(
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   143
            source_project  = 'project1.zip',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   144
            source_conf     = 'root1.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   145
            target_project  = None,
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   146
            target_conf     = 'root4.confml',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   147
            report_type     = 'data',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   148
            report_file     = 'data_p1r1_vs_p1r4.html',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   149
            check_against_expected_output = False)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   150
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   151
    def _run_comparison_test(self, **kwargs):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   152
        """
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   153
        Run comparison test.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   154
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   155
        @param source_project: The source project, relative to the test data directory or an
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   156
            absolute path.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   157
        @param source_conf: The source configuration.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   158
        @param target_project: The target project, relative to the test data directory
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   159
            If not given or None, the source project will be used also for this.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   160
        @param target_conf: The target configuration.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   161
        @param template: The template file used for the report, relative to the test data directory.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   162
        @param report_type: The report type. Should not be used with the 'template' parameter.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   163
        @param report_file: The location where the report is written. This will also be used as
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   164
            the name of the expected report file against which the actual report is checked.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   165
        @param impl_filter: Implementation filter to use.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   166
        @param check_against_expected_output: If True, the actual report is checked against an
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   167
            expected file with the same name. Otherwise it is just checked that the output
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   168
            file has been created and it contains something.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   169
        """
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   170
        # Get parameters
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   171
        # ---------------
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   172
        def get_project_absdir(project_dir):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   173
            if os.path.isabs(project_dir):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   174
                return project_dir
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   175
            else:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   176
                return os.path.normpath(os.path.join(TESTDATA_DIR, project_dir))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   177
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   178
        source_conf = kwargs['source_conf']
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   179
        target_conf = kwargs['target_conf']
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   180
        source_project = get_project_absdir(kwargs['source_project'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   181
        target_project = kwargs.get('target_project', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   182
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   183
        if target_project != None:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   184
            target_project = get_project_absdir(target_project)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   185
            target_conf = target_project + ';' + target_conf
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   186
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   187
        template = kwargs.get('template', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   188
        report_type = kwargs.get('report_type', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   189
        if template and report_type:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   190
            raise ValueError("Both 'template' and 'report_type' parameters given")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   191
        elif not template and not report_type:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   192
            raise ValueError("Neither 'template' not 'report_type' parameter given")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   193
        elif template:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   194
            template = os.path.normpath(os.path.join(TESTDATA_DIR, template))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   195
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   196
        report_file = kwargs['report_file']
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   197
        check_against_expected_output = kwargs['check_against_expected_output']
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   198
        actual_report = os.path.normpath(os.path.join(TEMP_DIR, report_file))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   199
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   200
        impl_filter = kwargs.get('impl_filter', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   201
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   202
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   203
        # Generate output
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   204
        # ----------------
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   205
        if report_type:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   206
            command = '%s -p "%s" -s "%s" -t "%s" --report-type "%s" --report "%s"' \
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   207
                % (get_cmd('compare'), source_project, source_conf, target_conf, report_type, actual_report)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   208
        else:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   209
            command = '%s -p "%s" -s "%s" -t "%s" --template "%s" --report "%s"' \
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   210
                % (get_cmd('compare'), source_project, source_conf, target_conf, template, actual_report)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   211
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   212
        if impl_filter:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   213
            command += ' --impl-filter "%s"' % impl_filter
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   214
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   215
        self.remove_if_exists(actual_report)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   216
        self.run_command(command)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   217
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   218
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   219
        # Check output
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   220
        # -------------
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   221
        if check_against_expected_output:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   222
            expected_report = os.path.normpath(os.path.join(TESTDATA_DIR, 'expected', report_file))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   223
            self.assert_file_contents_equal(expected_report, actual_report)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   224
        else:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   225
            self.assert_exists_and_contains_something(actual_report)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   226
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   227
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   228
if __name__ == '__main__':
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   229
      unittest.main()