示例#1
0
def test_wrapper():
    kv = {
        "name": "TESTING app", 
        "key": "x7456asdfasdf", 
        "age": 99,
        "emails": ["*****@*****.**","*****@*****.**"]
    }
    obj = objectwrapper(kv)
    assert obj.name == kv['name']
    assert len(obj.emails) == 2
    obj.attributes = []
    assert len(obj.attributes) == 0
    assert type(obj.attributes) == objectwrapper
    obj.attributes.append({'name':'name','value':True})
    assert len(obj.attributes) == 1
    assert obj.attributes[0].name == 'name'
示例#2
0
def test_json_body():
    'test json body posts work as well as args'
    http = tornado.httpclient.HTTPClient()
    url = '%s/api/email/not_an_existing_template3.json?apikey=%s'  % (options.demisauce_url,options.demisauce_api_key)
    email_dict = {
        "subject":"Welcome To Demisauce",
        "slug":"not_an_existing_template3",
        "from_email":"*****@*****.**",
        "from_name":"Demisauce Admin",
        "template": "Welcome to Demisauce;\n\n\nYour account has been enabled, and you can start using services on demisauce.\n\nTo verify your account you need to click and finish registering $link\n\nThank You\n\nDemisauce Team"
    }
    json_str = json.dumps(email_dict)
    email_result = http.fetch(url,method="POST",body=json_str)
    email = objectwrapper(json.loads(email_result.body))
    assert email.subject == email_dict['subject']
    email = Email.GET(id='not_an_existing_template3',cache=False)
    assert email._response.success == True
    assert email._response.status == 200
    assert email.subject == email_dict['subject']
    svc = Email(id='not_an_existing_template3')
    svc.DELETE()
    email = Email.GET(id='not_an_existing_template3',cache=False)
    assert email is None