<commit_before>import os

from attest import Assert, Tests, TestBase, test

import pyhis


class TWDBTestBase(TestBase):
    """Base class for using TWDB dataset as a source"""

    @test
    def check_sites(self):
        assert Assert(len(self.source.sites)) == 74

    @test
    def check_variables(self):
        assert Assert(len(self.source.sites['Aransas95_D1'].variables)) == 5
        assert Assert(len(self.source.sites['ULM95_3C'].variables)) == 5

    @test
    def check_dataframe(self):
        df = self.source.sites['Aransas95_D1'].dataframe
        assert Assert(len(df['SAL001'])) == 706
        df2 = self.source.sites['ULM95_3C'].dataframe
        assert Assert(len(df['SAL001'])) == 706



class TWDBFreshCacheTests(TWDBTestBase):
    """
    Run tests with cache backend
    """

    def __context__(self):
        if os.path.exists(pyhis.cache.CACHE_DATABASE_FILE):
            os.remove(pyhis.cache.CACHE_DATABASE_FILE)
        self.source = pyhis.Source(
            'http://his.crwr.utexas.edu/TWDB_Sondes/cuahsi_1_0.asmx?WSDL',
            use_cache=True)
        yield
        del self.source


class TWDBCacheTests(TWDBTestBase):
    """
    Run tests with cache backend<commit_msg>make sure the FreshCacheTests() reinitializes (calls create_all()) on the db each time<commit_after>import os

from attest import Assert, Tests, TestBase, test

import pyhis


class TWDBTestBase(TestBase):
    """Base class for using TWDB dataset as a source"""

    @test
    def check_sites(self):
        assert Assert(len(self.source.sites)) == 74

    @test
    def check_variables(self):
        assert Assert(len(self.source.sites['Aransas95_D1'].variables)) == 5
        assert Assert(len(self.source.sites['ULM95_3C'].variables)) == 5

    @test
    def check_dataframe(self):
        df = self.source.sites['Aransas95_D1'].dataframe
        assert Assert(len(df['SAL001'])) == 706
        df2 = self.source.sites['ULM95_3C'].dataframe
        assert Assert(len(df['SAL001'])) == 706



class TWDBFreshCacheTests(TWDBTestBase):
    """
    Run tests with cache backend
    """

    def __context__(self):
        if os.path.exists(pyhis.cache.CACHE_DATABASE_FILE):
            os.remove(pyhis.cache.CACHE_DATABASE_FILE)
        import cache
        cache.init()
        self.source = pyhis.Source(
            'http://his.crwr.utexas.edu/TWDB_Sondes/cuahsi_1_0.asmx?WSDL',
            use_cache=True)
        yield
        del self.source


class TWDBCacheTests(TWDBTestBase):
    """
    Run tests with cache backend
{'fraction_non_alphanumeric': 0.1194324004729996, 'fraction_numerical': 0.024438312968072525, 'mean_word_length': 2.928792569659443, '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': '7097758', 'n_tokens_mistral': 893, 'n_tokens_neox': 813, 'n_words': 165}