def _cleanup_test_data(name, objects_list, name_attribute):
    try:
        test_objects = []
        for test_object in objects_list:
            object_name = getattr(test_object, name_attribute)
            if is_test_object_name(object_name):
                test_objects.append(test_object)
        log_deleted_objects(test_objects, name)
        fixtures.tear_down_test_objects(test_objects)
    except UnexpectedResponseError as e:
        logger.error('Cannot cleanup {}s, reason: {}'.format(name, e))
Esempio n. 2
0
def remove_hive_databases():
    hive = Hive()
    dbs = hive.exec_query("show databases;")
    dbs = filter(lambda name: is_test_object_name(name), dbs)
    dbs = list(dbs)

    if dbs:
        logger.info("Removing databases:\n{}".format("\n".join(dbs)))
        dbs = map(lambda name: "DROP DATABASE {} CASCADE;".format(name), dbs)
        dbs = "".join(dbs)
        hive.exec_query(dbs)
    else:
        logger.info("No database to remove.")
Esempio n. 3
0
    dbs = filter(lambda name: is_test_object_name(name), dbs)
    dbs = list(dbs)

    if dbs:
        logger.info("Removing databases:\n{}".format("\n".join(dbs)))
        dbs = map(lambda name: "DROP DATABASE {} CASCADE;".format(name), dbs)
        dbs = "".join(dbs)
        hive.exec_query(dbs)
    else:
        logger.info("No database to remove.")


if __name__ == "__main__":

    all_data_sets = DataSet.api_get_list()
    test_data_sets = [x for x in all_data_sets if is_test_object_name(x.title)]
    log_deleted_objects(test_data_sets, "data set")
    fixtures.tear_down_test_objects(test_data_sets)

    all_transfers = Transfer.api_get_list()
    test_transfers = [x for x in all_transfers if is_test_object_name(x.title)]
    log_deleted_objects(test_transfers, "transfer")
    fixtures.tear_down_test_objects(test_transfers)

    all_users = User.cf_api_get_all_users()
    test_users = [x for x in all_users if is_test_object_name(x.username)]
    log_deleted_objects(test_users, "user")
    fixtures.tear_down_test_objects(test_users)

    all_pending_invitations = Invitation.api_get_list()
    test_invitations = [
Esempio n. 4
0
 def test_too_long_generated_addresses(self):
     test_email_address = generate_test_object_name(email=True,
                                                    prefix="test" * 7)
     assert len(test_email_address.split("@")[0]) <= 64
     assert is_test_object_name(test_email_address)
Esempio n. 5
0
 def test_negative_cases(self, name):
     step('Testing if {} is recognized as test object name'.format(name))
     assert not is_test_object_name(name)
Esempio n. 6
0
 def test_positive_cases_with_unique_id(self, args_combination):
     config.unique_id = '1'
     name = generate_test_object_name(*args_combination)
     step('Testing if {} is recognized as test object name'.format(name))
     assert is_test_object_name(name)
Esempio n. 7
0
 def test_positive_cases(self, args_combination):
     name = generate_test_object_name(*args_combination)
     step('Testing if {} is recognized as test object name'.format(name))
     assert is_test_object_name(name)