<commit_before>"""
Test the build process
"""
#TODO: we should really test the CLI interface itself, rather than
#the functions that cli calls
import os

try:
    import fastparquet
except ImportError:
    fastparquet = None

try:
    import pyarrow
except ImportError:
    pyarrow = None

import pytest

from ..tools.package import ParquetLib, Package
from ..tools import build
from .utils import QuiltTestCase


PACKAGE = 'groot'

class BuildTest(QuiltTestCase):
    def test_build_hdf5(self):
        """
        Test compilation
        """
        mydir = os.path.dirname(__file__)
        path = os.path.join(mydir, './build.yml')
        build.build_package('test_hdf5', PACKAGE, path)
        # TODO load DFs based on contents of .yml file at PATH
        # not hardcoded vals (this will require loading modules from variable
        # names, probably using __module__)
        from quilt.data.test_hdf5.groot import dataframes, README
        csv = dataframes.csv
        tsv = dataframes.csv
        xls = dataframes.xls
        rows = len(csv.index)
        assert rows == len(tsv.index) and rows == len(xls.index), \
            'Expected dataframes to have same # rows'
        assert os.path.exists(README)
        cols = len(csv.columns)
        print(csv.columns, xls.columns, tsv.columns)
        assert cols == len(tsv.columns) and cols == len(xls.columns), \
            'Expected dataframes to have same # columns'

        path = os.path.join(mydir, './build_bad_transform.yml')
        try: 
            build.build_package('test_hdf5_transform', PACKAGE, path)
            assert true, 'Expected build_bad_transform.yml to fail'
        except build.BuildException:
            pass

        path = os.path.join(mydir, './build_bad_file.yml')
        try: 
            build.build_package('test_hdf5_file', PACKAGE, path)
            assert true, 'Expected build_bad_file.yml to fail'
        except build.BuildException:
            pass

        # TODO add more integrity checks, incl. negative test cases

    @pytest.mark.skipif("fastparquet is None and pyarrow is None")
    def test_build_parquet_default(self):<commit_msg>Fix tests for invalid builds (#67)<commit_after>"""
Test the build process
"""
#TODO: we should really test the CLI interface itself, rather than
#the functions that cli calls
import os

try:
    import fastparquet
except ImportError:
    fastparquet = None

try:
    import pyarrow
except ImportError:
    pyarrow = None

import pytest

from ..tools.package import ParquetLib, Package
from ..tools import build
from .utils import QuiltTestCase


PACKAGE = 'groot'

class BuildTest(QuiltTestCase):
    def test_build_hdf5(self):
        """
        Test compilation
        """
        mydir = os.path.dirname(__file__)
        path = os.path.join(mydir, './build.yml')
        build.build_package('test_hdf5', PACKAGE, path)
        # TODO load DFs based on contents of .yml file at PATH
        # not hardcoded vals (this will require loading modules from variable
        # names, probably using __module__)
        from quilt.data.test_hdf5.groot import dataframes, README
        csv = dataframes.csv
        tsv = dataframes.csv
        xls = dataframes.xls
        rows = len(csv.index)
        assert rows == len(tsv.index) and rows == len(xls.index), \
            'Expected dataframes to have same # rows'
        assert os.path.exists(README)
        cols = len(csv.columns)
        print(csv.columns, xls.columns, tsv.columns)
        assert cols == len(tsv.columns) and cols == len(xls.columns), \
            'Expected dataframes to have same # columns'

        path = os.path.join(mydir, './build_bad_transform.yml')
        with self.assertRaises(build.BuildException):
            build.build_package('test_hdf5_transform', PACKAGE, path)

        path = os.path.join(mydir, './build_bad_file.yml')
        with self.assertRaises(build.BuildException):
            build.build_package('test_hdf5_file', PACKAGE, path)

        # TODO add more integrity checks, incl. negative test cases

    @pytest.mark.skipif("fastparquet is None and pyarrow is None")
    def test_build_parquet_default(self):
{'fraction_non_alphanumeric': 0.09241478636581853, 'fraction_numerical': 0.0028804608737397984, 'mean_word_length': 2.636125654450262, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7215019', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1222, 'n_words': 362}