示例#1
0
 def test_exception_raised(self):
     """
     Test: An exception is raised creating the user.
     Expected result: Error message returned.
     """
     original_get_or_create_user = ajax.logic.get_or_create_user
     ajax.logic.get_or_create_user = raise_exception
     
     
     json_ret = ajax.process_cards(None, "token", "name", "uid", "email")
     json_ret = json.loads(json_ret)
     
     ajax.logic.get_or_create_user = original_get_or_create_user
     
     self.assertEqual(json_ret["user_url"], "", "User url returned when none were expected.")
     self.assertNotEqual(json_ret["error"], "", "Error not raised.")
     self.assertTrue(EXCEPTION_STRING in json_ret["error"], "Wrong exception returned")
示例#2
0
 def test_proess_cards(self):
     """
     Test: User is retrieved.
     Expected result: No exceptions are raised
     """
     #Create a user for the test
     name = "moo"
     uid = "1234"
     token = "some token"
     email = "*****@*****.**"
     
     new_user = logic.get_or_create_user(token, name, uid, email)
     
     #Try and retreive it and see the info is the same:
     json_info = ajax.process_cards(None, token, name, uid, email)
     
     created_url = json.loads(json_info)["user_url"]
     
     retrieved_user = models.FeedUser.objects.get(url = created_url)
     
     self.assertEqual(retrieved_user.user_name , name, "User name is wrong.")
     self.assertEqual(retrieved_user.trello_member_id , uid, "User uid is wrong.")
     self.assertEqual(retrieved_user.user_token , token, "User token is wrong.")
     self.assertEqual(retrieved_user.email , email, "User email is wrong.")