Ejemplo n.º 1
0
	def test_error_invalid_userid(self):
		#not integer
		with self.assertRaises(APIInvalidParameterException):
			api.getMyComments("text")
		#doesn't exist
		with self.assertRaises(ObjectDoesNotExist):
			api.getMyComments(-1)
Ejemplo n.º 2
0
def getMyComments(request):
	usr = request.user.id
	try:
	    comments = api.getMyComments(int(usr))
	    returnJSON = serializers.serialize("json", comments, indent = 4, relations = ('comment', 'discussion'), extras=('__unicode__', 'presentationTitle'))
	except APIException as e:
		response = dict(error = "There was a problem with your request. Please try again.")
		api.log_error("APIException thrown ("+str(type(e))+"): "+e.value)
		returnJSON = simplejson.dumps(response)
	return HttpResponse(returnJSON, mimetype='application/json')
Ejemplo n.º 3
0
	def test_normal(self):
		userid = USER_ID
		comments = api.getMyComments(userid)
		if(len(comments) != 3):
			self.fail("Returned the wrong amount of comments.")
		if SYNOTE_TESTS_ON:
			for comment in comments:
				if api.isDiscussionComment(comment.comment):
					self.assertEquals(comment.presentationTitle, PRESENTATION_TITLE)
				else:
					self.assertEquals(comment.synmark["presentationTitle"], PRESENTATION_TITLE)
Ejemplo n.º 4
0
def commented(request):
	context = initContext(request.user)
	
	if request.user.is_authenticated():
		context["discussions"] = api.formatDiscussions(api.getMyDiscussions(request.user.id))
		context["comments"] = api.formatComments(api.getMyComments(request.user.id))
		context["notification"] = api.getNotifications(request.user.id)
	else:
		context["error_text"] = "You may need to <a href='/'>login</a>."
		return render(request, 'apierror.html', context)
	
	return render(request, 'commented.html', context)
Ejemplo n.º 5
0
	def test_normal(self):
		#just checking for errors currently
		comments = api.formatComments(api.getMyComments(USER_ID))