Example #1
0
def test_url_factory():
    path = "tests/factories/factory_utils/dir/default/default.txt"
    with open(path, "r") as f:
        data = f.read()
    base_url = "https://raw.githubusercontent.com/LucaCappelletti94/zipf/master/tests/factories/factory_utils/text/"
    httpretty.register_uri(httpretty.GET, base_url + "default.txt", body=data)
    httpretty.register_uri(httpretty.GET, base_url + "empty.txt", body="")
    errors = factory_fails(ZipfFromUrl, "url", prepare)
    assert not errors, "errors occured:\n{}".format("\n".join(errors))
Example #2
0
def test_dir_factory():
    errors = []
    for d in ["dir", "multi_dir", "multi_paths"]:
        for pr in [None, prep, prep_word_filter, prep_cli, cli_no_interface]:
            for r in [None, run]:
                errors += factory_fails(ZipfFromDir, d, prepare=pr, run=r)
    try:
        f = ZipfFromDir()
        f.run(None)
        errors.append(
            "Running ZipfFromDir with None paths should raise an exception")
    except ValueError as e:
        pass
    assert not errors, "errors occured:\n{}".format("\n".join(errors))
def test_file_factory():
    errors = factory_fails(ZipfFromFile, "file", prepare)
    assert not errors, "errors occured:\n{}".format("\n".join(errors))
Example #4
0
def test_text_factory():
    errors = factory_fails(ZipfFromText, "text")
    assert not errors, "errors occured:\n{}".format("\n".join(errors))
Example #5
0
def test_list_factory():
    errors = factory_fails(ZipfFromList, "list")
    assert not errors, "errors occured:\n{}".format("\n".join(errors))