<commit_before># -*- coding: utf-8 -*-

from dlstats.fetchers import FETCHERS, FETCHERS_DATASETS
from dlstats.commands import cmd_fetchers

import unittest
from click.testing import CliRunner
from dlstats.tests.base import BaseTestCase, BaseDBTestCase, RESOURCES_DIR

class FakeFetcher():
    
    def __init__(self, **kwargs):
        pass

    def datasets_list(self):
        return ["dataset1"]

    def datasets_long_list(self):
        return [("dataset1", "Dataset1")]

class FetcherNoDBTestCase(BaseTestCase):

    # nosetests -s -v dlstats.tests.commands.test_commands_fetchers:FetcherNoDBTestCase

    def setUp(self):
        BaseTestCase.setUp(self)
        #TODO: mock ?
        self.backup_FETCHERS = FETCHERS.copy()
        FETCHERS["TEST"] = FakeFetcher

    def tearDown(self):
        BaseTestCase.tearDown(self)
        FETCHERS = self.backup_FETCHERS
        
    def test_list(self):
        runner = CliRunner()   
        result = runner.invoke(cmd_fetchers.cmd_list, [])
        self.assertEqual(result.exit_code, 0)

    def test_datasets(self):
        runner = CliRunner()
        result = runner.invoke(cmd_fetchers.cmd_dataset_list, ['-f', 'TEST'])
        self.assertEqual(result.exit_code, 0)
        self.assertTrue("dataset1" in result.output)<commit_msg>fixe command test<commit_after># -*- coding: utf-8 -*-

from unittest import mock
from click.testing import CliRunner
from dlstats.tests.base import BaseTestCase

class FakeFetcher():
    
    def __init__(self, **kwargs):
        pass

    def datasets_list(self):
        return [{"dataset_code": "dataset1", "name": "dataset 1"}]
    
FETCHERS = {"TEST": FakeFetcher}    

class FetcherNoDBTestCase(BaseTestCase):

    # nosetests -s -v dlstats.tests.commands.test_commands_fetchers:FetcherNoDBTestCase

    def test_list(self):
        runner = CliRunner()
        from dlstats.commands import cmd_fetchers   
        result = runner.invoke(cmd_fetchers.cmd_list, [])
        self.assertEqual(result.exit_code, 0)

    @mock.patch("dlstats.fetchers.FETCHERS", FETCHERS)
    def test_datasets(self):
        runner = CliRunner()
        from dlstats.commands import cmd_fetchers
        result = runner.invoke(cmd_fetchers.cmd_dataset_list, ['-f', 'TEST'])
        self.assertEqual(result.exit_code, 0)
        self.assertTrue("dataset1" in result.output)
{'fraction_non_alphanumeric': 0.1082693947144075, 'fraction_numerical': 0.005541346973572037, 'mean_word_length': 3.2364620938628157, 'pattern_counts': {'":': 3, '<': 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': '2883315', 'n_tokens_mistral': 753, 'n_tokens_neox': 730, 'n_words': 150}