Ejemplo n.º 1
0
 def post(self,*args, **kwargs):
     recevied_time=datetime.now().strftime("%Y-%m-%d:%H:%M:%S")
     self.set_header("Content-Type", "text/plain")
     try:
         bodydict=json.loads(self.request.body)
     except:
         self.write("NOT A VALID REQUEST TYPEd")
     if not validate_email(bodydict['email']):
         self.clear()
         self.write("EMAIL IS NOT VALIDATED")
     else:
         
         mo=webcontent(email=bodydict['email'],\
                    first_name=bodydict['first_name'],\
                    last_name=bodydict['last_name'],\
                    contact_number=bodydict['contact_number'],\
                    title=bodydict['title'],\
                    link=bodydict['link'],\
                    )
         webcontent.save(mo,self,validate=True) 
         
         self.on_response(bodydict,**{'recevied_time':recevied_time})
Ejemplo n.º 2
0
    def test_shuffle(self):
        # make sure the shuffled sequence does not lose any elements
        

        # should raise an exception for an immutable sequence
        loaded=True
        recevied_time=datetime.now().strftime("%Y-%m-%d:%H:%M:%S")
        body=open('data.json', mode='rw').read()
        bodydict=json.loads(body)
        self.assertIsInstance(bodydict,dict)
        self.assertTrue(validate_email(bodydict['email']))
        
        mo=webcontent(email=bodydict['email'],\
                      first_name=bodydict['first_name'],\
                      last_name=bodydict['last_name'],\
                      contact_number=bodydict['contact_number'],\
                      title=bodydict['title'],\
                      link=bodydict['link'],\
                      )
        webcontent.save(mo,self,validate=True) 
            
        self.on_response(bodydict)
        self.assertTrue(loaded)