def setUp(self):
		self.url = '/api/cmn/currency/'
		self.request_content_type = 'application/json'
		self.client = Client()

		currency = Dummies.get_or_create_currency()
		user = Dummies.get_or_create_user()
		self.client.login(username=user.username, password=Dummies.get_password())
Example #2
0
	def test_update_po_object_not_found_error(self):
		data = {
			'name': 'changed_name',
			'guid': Dummies.get_or_create_currency().guid
		}
		response = self.client.put(self.url, data = data, content_type = self.request_content_type)

		self.assertEqual(response.status_code, 404, response.content)
Example #3
0
	def test_create_new_po_name_length_error(self):
		post_data = {
			'name': 'the name is longer than thirty letters in a row',
			'currency_id': Dummies.get_or_create_currency().guid,
			'type_id': Dummies.get_or_create_po_type().guid
		}
		response = self.client.post(self.url, data = post_data, content_type = self.request_content_type)

		self.assertEqual(response.status_code, 400, response.content)

		content = json.loads(response.content)
		self.assertEqual(content.get('name')[0], 'Ensure this value has at most 30 characters (it has 47).', content.get('name')[0])
	def setUp(self):
		self.url = '/api/cmn/expenseitem/'
		self.request_content_type = 'application/json'
		self.client = Client()

		self.measure = Dummies.get_or_create_measure()
		self.category = Dummies.get_or_create_root_category()
		self.supplier = Dummies.get_or_create_supplier()
		self.currency = Dummies.get_or_create_currency()
		self.user = Dummies.get_or_create_user()
		self.client.login(username=self.user.username, password=Dummies.get_password())

		self.post_data = {
			'name': 'test_1',
			'description': 'test description',
			'currency_id': self.currency.guid,
			'measure_id': self.measure.guid,
			'category_id': self.category.guid,
		}
Example #5
0
	def test_create_new_po_success(self):
		post_data = {
			'name': 'new_payment_object',
			'currency_id': Dummies.get_or_create_currency().guid,
			'type_id': Dummies.get_or_create_po_type().guid
		}
		number_of_pos = len(PaymentObject.objects.all())

		response = self.client.post(self.url, data = post_data, content_type = self.request_content_type)

		self.assertEqual(response.status_code, 201, response.content)

		po = json.loads(response.content)

		self.assertIsInstance(po, dict, po)

		po = po.get(self.key)

		self.assertIn('guid', po)
		self.assertEqual(po['name'], post_data['name'])
		self.assertEqual(number_of_pos + 1, len(PaymentObject.objects.all()))