Пример #1
0

@lazy
def path_cleaner():  # "/foo/bar/8/J.eno"  =>  "8/J"
    def clean_path(path):
        return rx.search(path)[1]

    import re
    from os.path import sep
    s = re.escape(sep)
    rx = re.compile(''.join((s, '([A-Z0-9]', s, r'[A-Z0-9])\.eno\Z')))
    return clean_path


def this_one_dir():
    return fixture_directory_for('050-canon-main')


fixture_directory_for = functions_for('eno').fixture_directory_for


def subject_module():
    import kiss_rdb.storage_adapters_.eno._caching_layer as m
    return m


if __name__ == '__main__':
    unittest.main()

# #born
def dir_path_most_common():
    return functions_for('toml').fixture_directory_for('056-single-file')
Пример #3
0
from kiss_rdb_test.markdown_storage_adapter import collection_via_real_path
from kiss_rdb_test.common_initial_state import functions_for
import modality_agnostic.test_support.common as em
from modality_agnostic.test_support.common import \
        dangerous_memoize as shared_subject
import unittest

fixture_path = functions_for('markdown').fixture_path


class CommonCase(unittest.TestCase):
    def build_state_expecting_some_emssions(self, path):
        listener, emissions = em.listener_and_emissions_for(self, limit=1)
        attr_dcts, k = self.my_run(path, listener)
        emi, = emissions
        return EndState(attr_dcts, k, ((emi.channel, emi.payloader), ))

    def build_state_expecting_no_emissions(self, path):
        attr_dcts, k = self.my_run(path, failey_listener)
        return EndState(attr_dcts, k)

    def my_run(self, path, listener):
        coll = collection_via_real_path(path, listener)
        if coll is None:
            return (), None  # (Case2449)
        with coll.open_entity_traversal(listener) as ents:
            return _signature_via_ents(ents)

    do_debug = False

Пример #4
0
@lazy
def real_filesystem_read_only():
    # push this up whenever - use the real filesystem but the same testy hook
    from kiss_rdb import real_filesystem_read_only__ as fser
    fs = fser()  # not really necessary
    otr = fs.__class__(commit_file_rewrite=None)
    otr.FINISH_AS_HACKY_SPY = lambda: None
    return otr


def _lines_via_big_string_as_is(big_string):
    import kiss_rdb.storage_adapters_.toml.CUD_attributes_via_request as lib
    return lib.lines_via_big_string_(big_string)


common_args_head = functions_for('toml').common_args_head

# == general

_common_collection = '050-rumspringa'
_IID = 'INTERNAL_IDENTIFIER'

_success_exit_code = 0

if __name__ == '__main__':
    unittest.main()

# #history-A.1 they fixed their abuse of exceptions for some cases
# #born.
import kiss_rdb_test.markdown_storage_adapter as msa
from kiss_rdb_test import storage_adapter_canon
from kiss_rdb_test.common_initial_state import \
        unindent_with_dot_hack, functions_for
import modality_agnostic.test_support.common as em
from modality_agnostic.test_support.common import \
        dangerous_memoize as shared_subject
import unittest

toml_fixture_directory_for = functions_for('toml').fixture_directory_for
md_fixture_path = functions_for('markdown').fixture_path

# [2500 (2517) 2535)

canon = storage_adapter_canon.produce_agent()


class CommonCase(unittest.TestCase):
    def build_end_state_expecting_failure(self, also=None):
        return canon.build_end_state_expecting_failure_via(self, also)

    def resolve_collection(self, listener):
        path = self.given_path()
        if path is not None:
            return msa.collection_via_real_path(path, listener)
        x = self.given_pretend_file()
        return msa.collection_via_mixed_test_resource(x, listener)

    def given_path(self):
        pass
def _entities_file_path_for_2J():
    import os.path as os_path
    return os_path.join(dir_path_most_common(), 'entities', '2', 'J.toml')


@lazy
def dir_path_most_common():
    return fixture_directory_for('050-rumspringa')


@lazy
def dir_path_of_no_ent():
    return fixture_directory_for('000-no-ent')


fixture_directory_for = functions_for('toml').fixture_directory_for


def last_three_path_parts(path):
    import re
    return re.search(r'[^/]+(?:/[^/]+){2}$', path)[0]


def random_number_generator_for(random_number):
    def random_number_generator(pool_size):
        assert 32760 == pool_size
        counter.increment()
        assert 1 == counter.value
        return random_number
    counter = Counter()
    return random_number_generator