<commit_before>#^_^ coding: utf8 ^_^

import os
import mockfs
import teca.filesystem as tecafs
from six import next as _next
import teca.ConfigHandler as tecaconf
import unittest

class SameConfClass(object):
    def setUp(self):
        self.conf_path = "tests/test_data/configuration.json"
        self.conf_content = open(self.conf_path).read()
        self.starting_path = "tests/test_data/images/"
        self.conf = tecaconf.ConfigHandler(
            self.conf_path,
            {"starting_path": self.starting_path}
        )

        self.mfs = mockfs.replace_builtins()
        self.mfs.add_entries({
            "tests": {
                "test_data":{
                        "configuration.json" : self.conf_content,
                        "images": {
                            "cutegirlsarecute": {
                                "yukinon.jpg": "",
                                "charlotte.jpg": "",
                                "misato.bmp": ""
                            },
                            "hiddenfolder": {
                                "uselessdoc.txt": "useless content",
                                "uselessimage.png": ""
                            },
                            "emptyFolder": {},
                            "ohwait": {
                                "imagesonly": {
                                    "yukinon.jpg": "",
                                    "specialchàr.jpg": "",
                                    "thumb_lol.png": ""
                                }
                            },
                            "you": {
                               "shall": {
                                   "notpass": {
                                       "kaiki.gif": ""
                                   },
                                   "pass": {
                                       "eruna.jpg": ""
                                   }
                               }
                            }
                        }
                }
            }
        })
        for p, d, f in os.walk("tests"):
            print(p, d, f)

    def tearDown(self):
        mockfs.restore_builtins()

class TestWalk(SameConfClass, unittest.TestCase):

    def test_foldersAtRoot(self):
        _, folders, _ = _next(tecafs.walk("", self.conf))
        self.assertEqual(set(["emptyFolder", "you", "ohwait", "cutegirlsarecute"]),
                         set(folders))

class TestDirectoryIsEmpty(SameConfClass, unittest.TestCase):

    def test_rootIsNotEmpty(self):
        res = tecafs.isDirectoryEmpty("", self.conf)
        self.assertEqual(res, False)<commit_msg>remove forgotten logs<commit_after>#^_^ coding: utf8 ^_^

import os
import mockfs
import teca.filesystem as tecafs
from six import next as _next
import teca.ConfigHandler as tecaconf
import unittest

class SameConfClass(object):
    def setUp(self):
        self.conf_path = "tests/test_data/configuration.json"
        self.conf_content = open(self.conf_path).read()
        self.starting_path = "tests/test_data/images/"
        self.conf = tecaconf.ConfigHandler(
            self.conf_path,
            {"starting_path": self.starting_path}
        )

        self.mfs = mockfs.replace_builtins()
        self.mfs.add_entries({
            "tests": {
                "test_data":{
                        "configuration.json" : self.conf_content,
                        "images": {
                            "cutegirlsarecute": {
                                "yukinon.jpg": "",
                                "charlotte.jpg": "",
                                "misato.bmp": ""
                            },
                            "hiddenfolder": {
                                "uselessdoc.txt": "useless content",
                                "uselessimage.png": ""
                            },
                            "emptyFolder": {},
                            "ohwait": {
                                "imagesonly": {
                                    "yukinon.jpg": "",
                                    "specialchàr.jpg": "",
                                    "thumb_lol.png": ""
                                }
                            },
                            "you": {
                               "shall": {
                                   "notpass": {
                                       "kaiki.gif": ""
                                   },
                                   "pass": {
                                       "eruna.jpg": ""
                                   }
                               }
                            }
                        }
                }
            }
        })

    def tearDown(self):
        mockfs.restore_builtins()

class TestWalk(SameConfClass, unittest.TestCase):

    def test_foldersAtRoot(self):
        _, folders, _ = _next(tecafs.walk("", self.conf))
        self.assertEqual(set(["emptyFolder", "you", "ohwait", "cutegirlsarecute"]),
                         set(folders))

class TestDirectoryIsEmpty(SameConfClass, unittest.TestCase):

    def test_rootIsNotEmpty(self):
        res = tecafs.isDirectoryEmpty("", self.conf)
        self.assertEqual(res, False)
{'fraction_non_alphanumeric': 0.10361904761904762, 'fraction_numerical': 0.00038095238095238096, 'mean_word_length': 0.9255592225889255, 'pattern_counts': {'":': 46, '<': 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': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4299732', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1269, 'n_words': 196}