<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import unittest
import shutil

from ludobox.config import read_config, validate_config

TEST_DATA_DIR = '/tmp/test-data'

class TestLudoboxConfig(unittest.TestCase):
    """Testing the load/write config for the Ludobox"""

    def setUp(self):
        """Init the tests"""

        data_dir = os.path.join(os.getcwd(),"data")
        index_path = os.path.join(data_dir, 'index.json')

        if os.path.exists(TEST_DATA_DIR):
            shutil.rmtree(TEST_DATA_DIR)
        os.makedirs(TEST_DATA_DIR)

        self.default_values = {
            "web_server_url" : None,
            "port" : 8080,
            "data_dir" : data_dir,
            "index_path" :index_path,
            "ludobox_name" : "My LudoBox",
            "upload_allowed" : True,
            "database_uri" : "sqlite:////tmp/ludobox.db",
            "max_file_size" : 20
        }

    def test_read_config_default(self):
        """Default config should have correct values"""

        config = read_config()

        # make sure keys are the same
        self.assertEquals(len(config.keys()), len(self.default_values.keys()) )
        print config.keys()
        self.assertEquals(sorted(config.keys()), sorted(self.default_values.keys()))
        self.assertEquals(config, self.default_values)

    def test_read_config_custom_values(self):
        """Config should parse value from the config file"""
        test_config_file = os.path.join(os.getcwd(),"server/tests/config.test.yml")
        config = read_config(config_path=test_config_file)

        self.assertEquals(config["port"], 4000)
        self.assertEquals(config["ludobox_name"], "My Testing LudoBox")
        self.assertEquals(config["web_server_url"], "http://localhost:8080")
        self.assertEquals(config["database_uri"], "sqlite:////tmp/test-for-testing.db")

        # tests file and dir paths<commit_msg>config: fix tests for web_server_url<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import unittest
import shutil

from ludobox.config import read_config, validate_config

TEST_DATA_DIR = '/tmp/test-data'

class TestLudoboxConfig(unittest.TestCase):
    """Testing the load/write config for the Ludobox"""

    def setUp(self):
        """Init the tests"""

        data_dir = os.path.join(os.getcwd(),"data")
        index_path = os.path.join(data_dir, 'index.json')

        if os.path.exists(TEST_DATA_DIR):
            shutil.rmtree(TEST_DATA_DIR)
        os.makedirs(TEST_DATA_DIR)

        self.default_values = {
            "web_server_url" : "http://box.ludobox.net",
            "port" : 8080,
            "data_dir" : data_dir,
            "index_path" :index_path,
            "ludobox_name" : "My LudoBox",
            "upload_allowed" : True,
            "database_uri" : "sqlite:////tmp/ludobox.db",
            "max_file_size" : 20
        }

    def test_read_config_default(self):
        """Default config should have correct values"""

        config = read_config()

        # make sure keys are the same
        self.assertEquals(len(config.keys()), len(self.default_values.keys()) )
        print config.keys()
        self.assertEquals(sorted(config.keys()), sorted(self.default_values.keys()))
        self.assertEquals(config, self.default_values)

    def test_read_config_custom_values(self):
        """Config should parse value from the config file"""
        test_config_file = os.path.join(os.getcwd(),"server/tests/config.test.yml")
        config = read_config(config_path=test_config_file)

        self.assertEquals(config["port"], 4000)
        self.assertEquals(config["ludobox_name"], "My Testing LudoBox")
        self.assertEquals(config["web_server_url"], "http://localhost:8080")
        self.assertEquals(config["database_uri"], "sqlite:////tmp/test-for-testing.db")

        # tests file and dir paths
{'fraction_non_alphanumeric': 0.1319640564826701, 'fraction_numerical': 0.007702182284980745, 'mean_word_length': 2.7935735150925023, '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': '93268', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1182, 'n_words': 225}