Ejemplo n.º 1
0
	def test_add_tag(self):
		'''
		add_tag must add a new tag to the tab.
		'''
		#Anonymous user
		response = dajaxice_post(self.client, 'tags', 'add_tag', {'tab_id': self.tabs[0].id, 'tag': 'lifestyle'})
		self.assertFalse(json.loads(response.content)['success'])
		
		#Logged in user
		self.client.login(email=self.user_email, password=self.user_pass)
		response = dajaxice_post(self.client, 'tags', 'add_tag', {'tab_id': self.tabs[0].id, 'tag': 'lifestyle'})
		self.assertTrue(json.loads(response.content)['success'])

		#Invalid tab id
		response = dajaxice_post(self.client, 'tags', 'add_tag', {'tab_id': 100, 'tag': 'lifestyle'})
		self.assertFalse(json.loads(response.content)['success'])
Ejemplo n.º 2
0
	def test_delete_tag(self):
		'''
		delete_tag must delete a valid tag
		'''
		#Anonymous user
		response = dajaxice_post(self.client, 'tags', 'delete_tag', {'tab_id': self.tabs[0].id, 'tag': self.tags[0]})
		self.assertFalse(json.loads(response.content)['success'])

		#Logged in user
		self.client.login(email=self.user_email, password=self.user_pass)
		response = dajaxice_post(self.client, 'tags', 'delete_tag', {'tab_id': self.tabs[0].id, 'tag': self.tags[0]})
		self.assertTrue(json.loads(response.content)['success'])

		#Invalid tab id
		response = dajaxice_post(self.client, 'tags', 'delete_tag', {'tab_id': 100, 'tag': self.tags[0]})
		self.assertFalse(json.loads(response.content)['success'])

		#Un-associated tag
		response = dajaxice_post(self.client, 'tags', 'delete_tag', {'tab_id': 100, 'tag': 'lifestyle'})
		self.assertFalse(json.loads(response.content)['success'])