def test_against_standard(self, standard_pars):
        """Compare a generated association against a standard
        Success is when no other AssertionError occurs.
        """
        if standard_pars.xfail is not None:
            pytest.xfail(reason=standard_pars.xfail)

        # Create the associations
        generated_path = Path('generate')
        generated_path.mkdir()
        version_id = standard_pars.pool_root.replace('_', '-')
        args = standard_pars.main_args + [
            '-p',
            str(generated_path),
            '--version-id',
            version_id,
        ]
        pool = combine_pools(
            [t_path(Path('data') / (standard_pars.pool_root + '.csv'))])
        Main(args, pool=pool)

        # Retrieve the truth files
        truth_paths = [
            self.get_data(truth_path) for truth_path in self.data_glob(
                *self.ref_loc, glob='*_' + version_id + '_*.json')
        ]

        # Compare the association sets.
        try:
            compare_asn_files(generated_path.glob('*.json'), truth_paths)
        except AssertionError:
            if standard_pars.xfail:
                pytest.xfail(standard_pars.xfail)
            else:
                raise
示例#2
0
def test_fromfiles():
    """Test from files

    Success is the fact that no errors happen.
    """
    with open('test.json', 'w') as fh:
        json.dump(standard_asn, fh)

    asn_diff.compare_asn_files(['test.json'], ['test.json'])
示例#3
0
def test_fromfiles():
    """Test from files

    Success is the fact that no errors happen.
    """
    with open('test.json', 'w') as fh:
        json.dump(standard_asn, fh)

    asn_diff.compare_asn_files(['test.json'], ['test.json'])
示例#4
0
    def test_against_standard(self, pool_path, slow):
        """Compare a generated association against a standard

        Success is when no other AssertionError occurs.
        """

        # Parse pool name
        pool = Path(pool_path).stem
        proposal, version_id = pool_regex.match(pool).group('proposal', 'versionid')
        special = SPECIAL_POOLS.get(pool, SPECIAL_DEFAULT)

        if special['slow'] and not slow:
            pytest.skip('Pool {pool} requires "--slow" option')

        # Create the generator running arguments
        generated_path = Path('generate')
        generated_path.mkdir()
        args = special['args'] + [
            '-p', str(generated_path),
            '--version-id', version_id,
            self.get_data(pool_path)
        ]

        # Create the associations
        asn_generate(args)

        # Retrieve the truth files
        asn_regex = re.compile(
            r'.+{proposal}.+{version_id}(_[^_]+?_[^_]+?_asn\.json)$'.format(
                proposal=proposal, version_id=version_id
            ),
            flags=re.IGNORECASE
        )
        truth_paths = [
            self.get_data(truth_path)
            for truth_path in self.truth_paths
            if asn_regex.match(truth_path)
        ]

        # Compare the association sets.
        try:
            compare_asn_files(generated_path.glob('*.json'), truth_paths)
        except AssertionError:
            if special['xfail']:
                pytest.xfail(special['xfail'])
            else:
                raise
示例#5
0
    def test_against_standard(self, pool_path):
        """Compare a generated association against a standard

        Success is when no other AssertionError occurs.
        """

        # Parse pool name
        pool = Path(pool_path).stem
        proposal, version_id = pool_regex.match(pool).group('proposal', 'versionid')

        # Create the associations
        generated_path = Path('generate')
        generated_path.mkdir()
        asn_generate([
            '--no-merge',
            '-p', str(generated_path),
            '--version-id', version_id,
            self.get_data(pool_path)
        ])

        # Retrieve the truth files
        asn_regex = re.compile(
            r'.+{proposal}.+{version_id}(_[^_]+?_[^_]+?_asn\.json)$'.format(
                proposal=proposal, version_id=version_id
            ),
            flags=re.IGNORECASE
        )
        truth_paths = [
            self.get_data(truth_path)
            for truth_path in asn_base.truth_paths
            if asn_regex.match(truth_path)
        ]

        # Compare the association sets.
        try:
            compare_asn_files(generated_path.glob('*.json'), truth_paths)
        except AssertionError as error:
            if 'Associations do not share a common set of products' in str(error):
                pytest.xfail('Issue #3039')
            else:
                raise
def test_against_standard(sdpdata_module, pool_path, slow):
    """Compare a generated association against a standard

    Success is when no other AssertionError occurs.
    """

    # Parse pool name
    pool = Path(pool_path).stem
    proposal, version_id = pool_regex.match(pool).group(
        'proposal', 'versionid')
    special = SPECIAL_POOLS.get(pool, SPECIAL_DEFAULT)

    if special['slow'] and not slow:
        pytest.skip(f'Pool {pool} requires "--slow" option')

    # Setup test path
    cwd = Path(pool)
    cwd.mkdir()
    with pushdir(cwd):

        # Create the generator running arguments
        output_path = Path(pool)
        output_path.mkdir()
        sdpdata_module.output = str(output_path)
        args = special['args'] + [
            '-p', sdpdata_module.output, '--version-id', version_id,
            sdpdata_module.get_data(pool_path)
        ]

        # Create the associations
        asn_generate(args)

        # Compare to the truth associations.
        truth_paths = sdpdata_module.truth_paths(pool)
        try:
            compare_asn_files(output_path.glob('*.json'), truth_paths)
        except AssertionError:
            if special['xfail']:
                pytest.xfail(special['xfail'])
            else:
                raise
示例#7
0
    def test_against_standard(self, pool_path):
        """Compare a generated association against a standard

        Success is when no other AssertionError occurs.
        """

        # Parse pool name
        pool = Path(pool_path).stem
        proposal, version_id = pool_regex.match(pool).group(
            'proposal', 'versionid')

        # Create the associations
        generated_path = Path('generate')
        generated_path.mkdir()
        asn_generate([
            '--no-merge', '-p',
            str(generated_path), '--version-id', version_id,
            self.get_data(pool_path)
        ])

        # Retrieve the truth files
        asn_regex = re.compile(
            r'.+{proposal}.+{version_id}(_[^_]+?_[^_]+?_asn\.json)$'.format(
                proposal=proposal, version_id=version_id),
            flags=re.IGNORECASE)
        truth_paths = [
            self.get_data(truth_path) for truth_path in ASN_BASE.truth_paths
            if asn_regex.match(truth_path)
        ]

        # Compare the association sets.
        try:
            compare_asn_files(generated_path.glob('*.json'), truth_paths)
        except AssertionError as error:
            if 'Associations do not share a common set of products' in str(
                    error):
                pytest.xfail('Issue #3039')
            else:
                raise
示例#8
0
    def test_against_standard(self, standard_pars):
        """Compare a generated assocaition against a standard

        Success is when no other AssertionError occurs.
        """
        if standard_pars.xfail is not None:
            pytest.xfail(reason=standard_pars.xfail)

        # Create the associations
        generated_path = Path('generate')
        generated_path.mkdir()
        version_id = standard_pars.pool_root.replace('_', '-')
        args = TEST_ARGS + standard_pars.main_args + [
            '-p', str(generated_path),
            '--version-id', version_id,
        ]
        pool = combine_pools([
            t_path(Path('data') / (standard_pars.pool_root + '.csv'))
        ])
        Main(args, pool=pool )

        # Retrieve the truth files
        truth_paths = [
            self.get_data(truth_path)
            for truth_path in self.data_glob(*self.ref_loc, glob='*_' + version_id + '_*.json')
        ]

        # Compare the association sets.
        try:
            compare_asn_files(generated_path.glob('*.json'), truth_paths)
        except AssertionError as error:
            if 'Associations do not share a common set of products' in str(error):
                pytest.xfail('Issue #3039')
            elif 'Associations have the following product name duplication' in str(error):
                pytest.xfail('Issue #3041')
            else:
                raise