def test_avro(): "test avro serializer" Site.serializer = AvroSchemaSerializer(Site.avroschema) # change default site = Site(site_dict) #print ("\nsite = %s, site_dict = %s" % (site,site_dict)) avrosite = site.to_format() site = Site(avrosite) #print avrosite assert site.name == site_dict['name'] print("type of this_isa_list = %s" % type(site.this_isa_list)) assert type(site.this_isa_list) == list assert'*****@*****.**' in site.this_isa_list assert site.enabled == True # now try by passing in serializer site = Site(avrosite,serializer=Site.serializer) assert site.name == site_dict['name'] assert type(site.this_isa_list) == list assert'*****@*****.**' in site.this_isa_list assert site.enabled == True
def test_site(): site_dict = { "name": "TESTING app", "key": "x7456asdfasdf", "email": "*****@*****.**", "slug": "unittesting", "base_url": "http://testing.demisauce.com", "enabled":"True", "this_is_extra":"this should go in extra json" } site = Site(site_dict) site.POST() assert site._response.success == True assert site._response.status == 201 assert site.id > 0 log.debug("created site.id=%s" % (site.id)) assert site.name == site_dict['name'] assert site.extra_json['this_is_extra'] == site_dict['this_is_extra'] # ok, now lets add different extra site2 = Site(id=site.id) assert site2.id == site.id site2.settings = [] site2.settings.append({'name':'mailchimp_api_key','value':'1234'}) site2.settings.append({'name':'testing_webhook','value':'http://localhost:4950/testwebhook','category':'event','event_type':'webhook','requires':['id','name']}) site2.extra_json = {'more_extra':'testing'} site2.POST() assert site.id == site2.id assert site.name == site2.name assert site2.extra_json['this_is_extra'] == site_dict['this_is_extra'] assert site2.extra_json['more_extra'] == 'testing' attr = site2.get_attribute('mailchimp_api_key') assert attr.name == 'mailchimp_api_key' assert attr.value == '1234' hook = site2.get_attribute('testing_webhook') assert hook.category == 'event' site.DELETE() site3 = Site.GET(site2.id) assert site3 is None
def test_wrapper(): site = Site(site_dict) sited = site.to_python()