示例#1
0
testcase.args.worker_password = testcase.args.worker_password or testcase.args.password
testcase.args.worker_keypath = testcase.args.worker_keypath or testcase.args.keypair

if not testcase.args.upload_manifest and not testcase.args.bundle_manifest:
    if (not testcase.args.url and not testcase.args.filepath) or (testcase.args.url and testcase.args.filepath):
        raise Exception('If manifest not provieded, either a URL or FILE path is required to create image ')

def make_image_public():
    emi = image_utils.tester.test_resources['images'][0]
    emi.set_launch_permissions(group_names=['all'])
    testcase.debug('\n---------------------------\nCreated EMI:' + str(emi) +'\n---------------------------')


#Create an ImageUtils helper from the arguments provided in this testcase...
image_utils = testcase.do_with_args(ImageUtils)

#Create a single testcase to wrap and run the EMI creation task. Note by default all the overlapping args from
# this testcase are fed to the testunit method when ran.
test1 = testcase.create_testunit_from_method(image_utils.create_emi)
test2 = testcase.create_testunit_from_method(make_image_public)

result = testcase.run_test_case_list([test1, test2], eof=True, clean_on_exit=False, printresults=True)

#By default created resources are stored in the eucaops/tester object's test_resources dict. See if our image is
#prsent. If so print it out...
if image_utils.tester.test_resources['images']:
    emi = image_utils.tester.test_resources['images'][0]
    testcase.debug('\n---------------------------\nCreated EMI:' + str(emi) +'\n---------------------------')

exit(result)
示例#2
0
test1 = testcase.create_testunit_from_method(my_first_test_method, autoarg=False, eof=False)

# Add Another test by method
test2 = testcase.create_testunit_from_method(too_lazy_to_run)

##################################################################################################
# Create this testunit obj by passing a name of a method local to the testcase object.           #
# Setting eof to True here will abort any remaining nephoria_unit_tests if this unit fails. This can also be   #
# set globally for all test units                                                                #
# during run_test_case_list()                                                                    #
##################################################################################################
test3 = testcase.create_testunit_by_name('uh_oh_fail', eof=True)

# Add one more test unit by method, this test should not be attempted since eof is set on a
# test intended to fail prior to this test
test4 = testcase.create_testunit_from_method(hope_i_get_to_run)


##################################################################################################
# Finally run the test list                                                                      #
##################################################################################################
result = testcase.run_test_case_list(list = [test0, test1, test2, test3, test4],
                                     eof=False,
                                     clean_on_exit=False,
                                     printresults=True)

##################################################################################################
# Dont forget to exit with the proper code                                                       #
##################################################################################################
exit(result)