Пример #1
0
def test_load_model_crawler_model_mapper_maps_types(
        crawler_inline_definitions: CrawlinoStore):

    m = CrawlinoModel(crawler_inline_definitions)

    assert all(
        isinstance(x, CMModelsMappersObject)
        for x in m.model.mappers.all()) == True
Пример #2
0
def test_load_model_crawler_model_fields_get(
        crawler_inline_definitions: CrawlinoStore):

    m = CrawlinoModel(crawler_inline_definitions)

    field_obj = m.model.fields.get("url")

    assert isinstance(field_obj, CMModelsField)

    assert field_obj.name == "url"
    assert field_obj.type == "text"
    assert field_obj.key == True
Пример #3
0
def test_load_input_import_not_type(crawler_inline_definitions: File):
    m = CrawlinoModel(crawler_inline_definitions)

    assert hasattr(m.input, "type")
Пример #4
0
def test_load_model_crawler_model_mapper_get_mapper(
        crawler_inline_definitions: CrawlinoStore):
    m = CrawlinoModel(crawler_inline_definitions)

    assert m.model.mappers.get("my_database").name == "my_database"
Пример #5
0
def test_load_model_crawler_model_mapper_check_format(
        check_model_mappers_invalid_format: File):

    with pytest.raises(CrawlinoFormatError):
        CrawlinoModel(check_model_mappers_invalid_format)
Пример #6
0
def test_load_model_crawler_model_mapper_loaded_maps(
        crawler_inline_definitions: CrawlinoStore):

    m = CrawlinoModel(crawler_inline_definitions)

    assert len(m.model.mappers.all()) == 4
Пример #7
0
def test_load_model_crawler_model_fields_check_duplicates(
        check_model_fields_duplicate_names: File):

    with pytest.raises(CrawlinoFormatError):
        CrawlinoModel(check_model_fields_duplicate_names)
Пример #8
0
def test_load_model_crawler_model_name(
        crawler_inline_definitions: CrawlinoStore):
    m = CrawlinoModel(crawler_inline_definitions)

    assert m.model.name == "my_model_1"
Пример #9
0
def test_load_config_ok(crawler_inline_definitions: File):
    m = CrawlinoModel(crawler_inline_definitions)

    assert isinstance(m.config, CMConfig)
Пример #10
0
def test_load_input_import_ok(crawler_import_definitions: File):
    m = CrawlinoModel(crawler_import_definitions)

    assert isinstance(m.input, CMInput)
Пример #11
0
def test_input_without_config(input_without_config: File):

    with pytest.raises(CrawlinoValueError):
        CrawlinoModel(input_without_config)
Пример #12
0
def test_input_without_type(input_without_type: File):

    with pytest.raises(CrawlinoValueError):
        CrawlinoModel(input_without_type)
Пример #13
0
def test_load_input_raises_invalid_valid_types(invalid_types: File):

    with pytest.raises(CrawlinoValueError):
        CrawlinoModel(invalid_types)
Пример #14
0
def test_load_input_inline_check_valid_types(crawler_import_definitions: File):
    m = CrawlinoModel(crawler_import_definitions)

    assert CrawlinoModulesStore.find_module("input", m.input.type) is not None
Пример #15
0
def test_load_input_inline_not_config(crawler_import_definitions: File):
    m = CrawlinoModel(crawler_import_definitions)

    assert hasattr(m.input, "config")
Пример #16
0
def test_sources_import_type_is_list(crawler_inline_definitions: File):
    m = CrawlinoModel(crawler_inline_definitions)

    assert isinstance(m.sources.get_list(), list)
Пример #17
0
def test_sources_empty_sources(empty_sources: File):

    with pytest.raises(CrawlinoValueError):
        CrawlinoModel(empty_sources)
Пример #18
0
def test_load_config_generic_logger_name(generic_logger_name: File):
    m = CrawlinoModel(generic_logger_name)

    assert m.config.logger == "crawlino"
Пример #19
0
def test_load_model_crawler_model_fields_check_type(
        crawler_inline_definitions: CrawlinoStore):

    m = CrawlinoModel(crawler_inline_definitions)

    assert isinstance(m.model.fields, CMModelsFields)
Пример #20
0
def test_load_config_custom_logger_name_inline(
        crawler_inline_definitions: File):
    m = CrawlinoModel(crawler_inline_definitions)

    assert m.config.logger == "mylogger"
Пример #21
0
def test_load_model_crawler_model_fields_not_found(
        crawler_inline_definitions: CrawlinoStore):
    m = CrawlinoModel(crawler_inline_definitions)

    with pytest.raises(CrawlinoNotFoundError):
        m.model.fields.get("aaaa")
Пример #22
0
def test_sources_check_each_element_type(crawler_import_definitions: File):
    m = CrawlinoModel(crawler_import_definitions)

    r = list(isinstance(x, CMSource) for x in m.sources.get_list())
    assert len(r) != 0 and all(r) is True
Пример #23
0
def test_load_model_crawler_model_mapper_check_type(
        crawler_inline_definitions: CrawlinoStore):

    m = CrawlinoModel(crawler_inline_definitions)

    assert isinstance(m.model.mappers, CMModelsMappers)
Пример #24
0
def test_sources_find_element(crawler_import_definitions: File):
    m = CrawlinoModel(crawler_import_definitions)

    assert isinstance(m.sources.find("dummySource"), CMSource)
Пример #25
0
def test_sources_check_is_iterable(crawler_import_definitions: File):
    m = CrawlinoModel(crawler_import_definitions)

    assert isinstance(m.sources, Iterable)
Пример #26
0
def test_sources_check_iteration(crawler_import_definitions: File):
    m = CrawlinoModel(crawler_import_definitions)

    content = list(m.sources)

    assert len(content) > 0 and all(isinstance(x, CMSource) for x in content)
Пример #27
0
def test_load_model_crawler_model_mapper_invalid_mapper(
        check_model_mappers_invalid_mapper: File):

    with pytest.raises(CrawlinoValueError):
        CrawlinoModel(check_model_mappers_invalid_mapper)
Пример #28
0
def test_sources_import_ok(crawler_import_definitions: File):
    m = CrawlinoModel(crawler_import_definitions)

    assert isinstance(m.sources, CMSources)
Пример #29
0
def test_load_model_crawler_model_mapper_get_mapper_non_exists(
        crawler_inline_definitions: CrawlinoStore):
    m = CrawlinoModel(crawler_inline_definitions)

    with pytest.raises(CrawlinoNotFoundError):
        m.model.mappers.get("XXXXX")
Пример #30
0
def test_load_hooks_import_check_hooks_types(crawler_import_definitions: TextIOWrapper):
    m = CrawlinoModel(crawler_import_definitions)

    v = all(isinstance(x, CMHook) for x in m.hooks.get_list())

    assert len(m.hooks.get_list()) > 0 and v is True