#pylint: disable=attribute-defined-outside-init
#pylint: disable=protected-access
#pylint: disable=no-self-use
#pylint: disable=empty-docstring

import sys
import os

from os.path import dirname, join as pjoin
from pprint import pprint as pp
import pytest

import datagristle.test_tools as test_tools

pgm_path = dirname(dirname(os.path.realpath(__file__)))
mod = test_tools.load_script(pjoin(pgm_path, 'gristle_file_converter'))



class TestOptsAndArgs(object):

    def _run_check(self, sysarg, expected_result):
        sys.argv = sysarg
        cmd_parser = None
        opts = None
        files = None
        if expected_result == 'SystemExit':
            with pytest.raises(SystemExit):
                cmd_parser = mod.CommandLineParser()
                opts = cmd_parser.opts
                files = cmd_parser.files
Exemplo n.º 2
0
#pylint: disable=protected-access
#pylint: disable=no-self-use
#pylint: disable=empty-docstring

import time
import datetime
import tempfile
import shutil
import os
from os.path import dirname, join as pjoin
import pytest

import datagristle.test_tools as test_tools

pgm_path = dirname(dirname(os.path.realpath(__file__)))
mod = test_tools.load_script(pjoin(pgm_path, 'gristle_processor'))


class TestProcessDir(object):
    def setup_method(self, method):
        self.tmpdir = tempfile.mkdtemp(prefix="gristle_processor_")
        for _ in range(20):
            suffix = '_2013-03-10_'
            create_file(self, age=None, suffix=suffix, mydir=self.tmpdir)

        self.kwargs = {
            'name': 'foobar',
            'gathering_phase': {
                'dir': '%s' % self.tmpdir
            },
            'inclusion_phase': {
#pylint: disable=attribute-defined-outside-init
#pylint: disable=protected-access
#pylint: disable=no-self-use

import tempfile
import random
import csv
import os
from os.path import dirname, join as pjoin
from pprint import pprint as pp

import datagristle.test_tools as test_tools
import datagristle.file_io as file_io

pgm_path = dirname(dirname(os.path.realpath((__file__))))
mod = test_tools.load_script(pjoin(pgm_path, 'gristle_freaker'))


class Test_build_freq(object):
    def setup_method(self, method):
        pass

    def teardown_method(self, method):
        test_tools.temp_file_remover(
            os.path.join(tempfile.gettempdir(), 'FreakerTest'))

    def test_multicol(self):

        dialect = csv.Dialect
        dialect.delimiter = '|'
        dialect.quoting = csv.QUOTE_MINIMAL
#pylint: disable=attribute-defined-outside-init
#pylint: disable=protected-access
#pylint: disable=no-self-use
#pylint: disable=empty-docstring

import tempfile
import shutil
import os
from os.path import dirname, join as pjoin

import envoy

import datagristle.test_tools as test_tools

pgm_path = dirname(dirname(os.path.realpath(__file__)))
mod = test_tools.load_script(pjoin(pgm_path, 'gristle_dir_merger'))



class TestCreateUniqueFileName(object):

    def setup_method(self, method):
        self.dir_name = tempfile.mkdtemp(prefix='test_gristle_dir_merger_')

    def teardown_method(self, method):
        shutil.rmtree(self.dir_name)

    def test_simple_file_name_with_extension(self):
        touch(os.path.join(self.dir_name, 'test.txt'))
        assert mod.create_unique_file_name(self.dir_name, 'test.txt') == 'test.1.txt'
#pylint: disable=attribute-defined-outside-init
#pylint: disable=protected-access
#pylint: disable=no-self-use

import tempfile
import random
import csv
import os
from os.path import dirname, join as pjoin
from pprint import pprint as pp

import datagristle.test_tools as test_tools
import datagristle.file_io as file_io

pgm_path = dirname(dirname(os.path.realpath((__file__))))
mod = test_tools.load_script(pjoin(pgm_path, 'gristle_freaker'))




class Test_build_freq(object):

    def setup_method(self, method):
        pass

    def teardown_method(self, method):
        test_tools.temp_file_remover(os.path.join(tempfile.gettempdir(), 'FreakerTest'))

    def test_multicol(self):

        dialect = csv.Dialect
Exemplo n.º 6
0
#adjust pylint for pytest oddities:
#pylint: disable=missing-docstring
#pylint: disable=unused-argument
#pylint: disable=attribute-defined-outside-init
#pylint: disable=protected-access
#pylint: disable=no-self-use

import sys
import os
from os.path import dirname, join as pjoin
from pprint import pprint as pp

import datagristle.test_tools as test_tools

pgm_path = dirname(dirname(os.path.realpath((__file__))))
MOD = test_tools.load_script(pjoin(pgm_path, 'gristle_differ'))


class TestGetAssignWithOffsetsForNames(object):

    def test_basics(self):
        col_names = ['col0', 'col1', 'col2', 'col3']
        config = [{"dest_file":"insert", "dest_field":"col0", "src_type":"copy",
                   "src_file":"old", "src_field":"col0"}]
        target_config = [{"dest_file":"insert", "dest_field":0,
                          "src_type":"copy",
                          "src_file":"old", "src_field":0}]
        print('target: ')
        pp(target_config)
        print('results: ')
        pp(MOD.get_assign_with_offsets_for_names(col_names, config))
Exemplo n.º 7
0
#adjust pylint for pytest oddities:
#pylint: disable=missing-docstring
#pylint: disable=unused-argument
#pylint: disable=attribute-defined-outside-init
#pylint: disable=protected-access
#pylint: disable=no-self-use

import sys
import os
from os.path import dirname, join as pjoin
from pprint import pprint as pp

import datagristle.test_tools as test_tools

pgm_path = dirname(dirname(os.path.realpath((__file__))))
MOD = test_tools.load_script(pjoin(pgm_path, 'gristle_differ'))


class TestGetAssignWithOffsetsForNames(object):
    def test_basics(self):
        col_names = ['col0', 'col1', 'col2', 'col3']
        config = [{
            "dest_file": "insert",
            "dest_field": "col0",
            "src_type": "copy",
            "src_file": "old",
            "src_field": "col0"
        }]
        target_config = [{
            "dest_file": "insert",
            "dest_field": 0,
Exemplo n.º 8
0
#pylint: disable=attribute-defined-outside-init
#pylint: disable=protected-access
#pylint: disable=no-self-use
#pylint: disable=empty-docstring

import sys
import os

from os.path import dirname, join as pjoin
from pprint import pprint as pp
import pytest

import datagristle.test_tools as test_tools

pgm_path = dirname(dirname(os.path.realpath(__file__)))
mod = test_tools.load_script(pjoin(pgm_path, 'gristle_file_converter'))


class TestOptsAndArgs(object):
    def _run_check(self, sysarg, expected_result):
        sys.argv = sysarg
        cmd_parser = None
        opts = None
        files = None
        if expected_result == 'SystemExit':
            with pytest.raises(SystemExit):
                cmd_parser = mod.CommandLineParser()
                opts = cmd_parser.opts
                files = cmd_parser.files
        elif expected_result == 'except':
            with pytest.raises(Exception):
Exemplo n.º 9
0
#pylint: disable=protected-access
#pylint: disable=no-self-use
#pylint: disable=empty-docstring

import time
import datetime
import tempfile
import shutil
import os
from os.path import dirname, join as pjoin
import pytest

import datagristle.test_tools as test_tools

pgm_path = dirname(dirname(os.path.realpath(__file__)))
mod = test_tools.load_script(pjoin(pgm_path, 'gristle_processor'))



class TestProcessDir(object):

    def setup_method(self, method):
        self.tmpdir = tempfile.mkdtemp(prefix="gristle_processor_")
        for _ in range(20):
            suffix = '_2013-03-10_'
            create_file(self, age=None, suffix=suffix, mydir=self.tmpdir)

        self.kwargs = {'name': 'foobar',
                       'gathering_phase': {'dir': '%s' % self.tmpdir},
                       'inclusion_phase': {
                           #'atime_gt': '100d',