Exemple #1
0
def veritas(csv_file, **kwargs):
    validator = VeritasValidor(csv_file)

    if not validator.validate():
        validator.print_errors()
    else:
        print("CSV file validated!")
Exemple #2
0
def _check_csv(csv_file):
    """
    Check validity of CSV file containing sites information

    Arguments keywords
    csv_file -- Path to CSV file

    Return
    Instance of VeritasValidator
    """
    validator = VeritasValidor(csv_file)

    # If errors found during validation
    if not validator.validate():
        for error in validator.errors:
            logging.error(error.message)
        raise SystemExit("Invalid CSV file!")

    return validator
Exemple #3
0
def backup_many(csv_file, backup_type=None, **kwargs):
    # use Veritas to get valid rows
    rows = VeritasValidor.filter_valid_rows(csv_file)

    # create a new WP site backup for each row
    print("\n{} websites will now be backuped...".format(len(rows)))
    for index, row in rows:
        logging.debug("%s - row %s: %s", row["wp_site_url"], index, row)
        WPBackup(openshift_env=row["openshift_env"],
                 wp_site_url=row["wp_site_url"],
                 wp_default_site_title=row["wp_default_site_title"],
                 backup_type=backup_type).backup()
Exemple #4
0
def test_validate():
    filename = os.path.join(CURRENT_DIR, TEST_FILE)

    validator = VeritasValidor(filename, columns=MOCK_JAHIA2WP_COLUMNS)

    # make sure test environment exists
    if not os.path.exists("/srv/test"):
        os.mkdir("/srv/test")

    validator.validate()

    errors = validator.errors

    assert "invalid wp_site_url" in errors[0].message
    assert "invalid site_type" in errors[1].message
    assert "wp_site_url is not unique" in errors[2].message
    assert "wp_site_url is not unique" in errors[3].message
    assert "invalid langs" in errors[4].message
    assert "invalid updates_automatic" in errors[5].message
    assert "wp_site_url is not unique" in errors[6].message
    assert "invalid openshift_env" in errors[7].message
    assert "wp_site_url is not unique" in errors[8].message
Exemple #5
0
def generate_many(csv_file, **kwargs):
    # use Veritas to get valid rows
    rows = VeritasValidor.filter_valid_rows(csv_file)

    # create a new WP site for each row
    print("\n{} websites will now be generated...".format(len(rows)))
    for index, row in rows:
        print("\nIndex #{}:\n---".format(index))
        logging.debug("%s - row %s: %s", row["wp_site_url"], index, row)
        WPGenerator(
            row["openshift_env"],
            row["wp_site_url"],
            row["unit_name"],
            wp_default_site_title=row["wp_default_site_title"],
            unit_name=row["unit_name"],
            updates_automatic=row["updates_automatic"],
            installs_locked=row["installs_locked"],
            theme=row["theme"],
            theme_faculty=row["theme_faculty"],
        ).generate()
Exemple #6
0
def test_filter_method():
    filename = os.path.join(CURRENT_DIR, TEST_FILE)
    valid_lines = (0, VALID_LINE)
    validator = VeritasValidor.filter_valid_rows(filename,
                                                 columns=MOCK_JAHIA2WP_COLUMNS)
    assert valid_lines[1] == validator[0][1]
Exemple #7
0
def test_get_valid_rows():
    filename = os.path.join(CURRENT_DIR, TEST_FILE)
    valid_lines = (0, VALID_LINE)
    validator = VeritasValidor(filename, columns=MOCK_JAHIA2WP_COLUMNS)
    assert validator.get_valid_rows()[0] == valid_lines
Exemple #8
0
def veritas(csv_file, **kwargs):
    validator = VeritasValidor(csv_file)

    validator.validate()

    validator.print_errors()