This is my test class and i am trying to unittest my method that is createaccount()
class CreateAccountTest1(unittest.TestCase):
def testCreateAccount_1(self,data):
text = "{'user_id':'abc123','action':'add','names':['hello','world']}"
regex = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.| [^"\\])*"/ g, ''))) && eval('(' + text + ')')
self.assertRegexpMatches(text, reg, 'my msg')
createaccount() method is
class CreateAccountClass():
def CreateAccount(self,data):
Now i have to check whether the parameter of the createaccount()
is in json format or not.
if i pass data=
{ "_id" : "user@gmail.com", "H_id" : "smsg0", "name" : "vish", "passwrd" : "xj45cd" }
it should check whether it is json or not,
and i am sure that this is in json format.
now in my method createaccount()
it should check whether the data
is in json format or not,
if not it should print error message, if it works with regex
? or any suggestions,
Thanks,