示例#1
0
def estimate_test(testset, server_url):
    for testdata in testset:
        # get
        estimate = AwsEstimate(server_url,'FIREFOX')
        estimate_json = estimate.getEstimate( testdata['saved_url'] , False )
        pp(estimate_json)
        print '-- Assert getEstimate: ' + testdata['comment']
        assert testdata['total'] == estimate_json['Estimate']['Total']
        # create
        ret = estimate.createEstimate(estimate_json)
        pp(ret)
        estimate.tearDown()
        estimate = None
        print '-- Assert createEstimate: ' + testdata['comment']
        assert testdata['total'] == ret['Estimate']['Total']
    --screen                   Take Sceenshot
"""

import sys, json
from docopt import docopt
from AwsEstimate import AwsEstimate

if __name__ == "__main__":
    args = docopt(__doc__, version="0.1.0")
    print >>sys.stderr, args
   
    filename = args['--file']
    fp=open(filename,'r')
    text=fp.read()
    fp.close()
    sysconf=json.loads(text)

    ac = AwsEstimate(
            server_url=args['--server'],
            driver_type=args['--driver'],
            file_prefix=args['--prefix']
        )
    ret = ac.createEstimate(
            system_conf=sysconf,
            screenshot=args['--screen'] 
        )
    ac.tearDown()

    output=json.dumps(ret, indent=4, ensure_ascii=False ).encode('utf-8')
    print output 
    -f,--file <filename>       Output filename
    -p,--prefix <file_prefix>  ScreenshotFile prefix name [default: aws-]
    --screen                   Take Sceenshot
"""

import sys, json
from docopt import docopt
from AwsEstimate import AwsEstimate

if __name__ == "__main__":
    args = docopt(__doc__, version="0.1.0")
    print >>sys.stderr, args

    ac = AwsEstimate(
            server_url=args['--server'],
            driver_type=args['--driver'],
            file_prefix=args['--prefix']
        )
    ret = ac.getEstimate(
            saved_url=args['--url'],
            screenshot=args['--screen']
        )
    ac.tearDown()

    output=json.dumps(ret, indent=4, ensure_ascii=False ).encode('utf-8')
    if args['--file'] :
        filename = args['--file']
        fp=open(filename,'w')
        print >> fp, output
        fp.close()
    else: