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

		measure = Dummies.get_or_create_measure()
		user = Dummies.get_or_create_user()
		self.client.login(username=user.username, password=Dummies.get_password())
Esempio n. 2
0
	def test_update_po_save_error(self):
		data = {
			'name': 'changed_name',
			'guid': Dummies.get_or_create_po().guid,
			'type_id': 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, 500, response.content)
Esempio n. 3
0
	def setUp(self):
		self.url = '/api/cmn/po/'
		self.request_content_type = 'application/json'
		self.client = Client()

		user = Dummies.get_or_create_user()
		po = Dummies.get_or_create_po()
		self.client.login(username=user.username, password=Dummies.get_password())
		self.key = 'po'
Esempio n. 4
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])
Esempio n. 5
0
	def test_create_new_po_save_error(self):
		post_data = {
			'name': 'new_payment_object',
			'currency_id': Dummies.get_or_create_po_type().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, 500, response.content)

		content = json.loads(response.content)
		self.assertEqual(content.get('message').get('text'), 'The error was occured during saving process')
	def setUp(self):
		self.url = '/api/cmn/category/'
		self.request_content_type = 'application/json'
		self.client = Client()

		self.root_category_level = Dummies.get_or_create_root_category_level()
		self.user = Dummies.get_or_create_user()
		self.client.login(username=self.user.username, password=Dummies.get_password())
		self.root_category = Dummies.get_or_create_root_category()

		self.post_data = {
			'name': '',
			'parent_guid': ''
		}
	def setUp(self):
		self.url = '/api/cmn/transaction/'
		self.request_content_type = 'application/json'
		self.client = Client()

		self.user = Dummies.get_or_create_user()
		self.po = Dummies.get_or_create_po()
		self.transaction_status_success = Dummies.get_or_create_transaction_status('success')
		self.client.login(username = self.user.username, password = Dummies.get_password())
		self.key = 'transaction'

		self.new_transaction = {
			'date': 1462969764591,
			'value': '50000',
			'payment_object_id': self.po.guid
		}
Esempio n. 8
0
	def test_authenticate_success(self):
		"""
		Test success
		"""
		result = authenticate(self.user.username, Dummies.get_password())

		self.assertEqual(result.is_succeed, True)
		self.assertEqual(result.data, User.objects.get(username='******'))
	def test_should_be_a_new_category_level_created(self):
		CategoryLevel.objects.all().delete()
		self.category_level = Dummies.get_or_create_root_category_level()

		levels_count = len(CategoryLevel.objects.all())

		category_level = CategoryLevel.objects.create_level()

		self.assertEqual(len(CategoryLevel.objects.all()), levels_count + 1)
Esempio n. 10
0
	def test_get_single_po_error(self):
		existing_po = Dummies.get_or_create_po()
		guid = existing_po.guid[5:] + 'test1'

		response = self.client.get(self.url + guid + '/', content_type = self.request_content_type)

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

		content = json.loads(response.content)
		self.assertEqual(content.get('message').get('text'), 'The object {guid} is\'n found'.format(guid=guid))
Esempio n. 11
0
	def test_get_single_po_success(self):
		existing_po = Dummies.get_or_create_po()

		response = self.client.get(self.url + existing_po.guid + '/', content_type=self.request_content_type)

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

		po = json.loads(response.content)

		self.assertIsInstance(po, dict, po)
		self.assertIn(self.key, po)
		self.assertEqual(po.get(self.key).get('guid'), existing_po.guid, po)
Esempio n. 12
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()))
	def setUp(self):
		"""
		Tests setups
		"""
		user = Dummies.get_or_create_user()

		self.url = '/api/auth/signin/'
		self.request_content_type = 'application/json'
		self.client = Client()
		self.data = {
			'username': '******',
			'password': '******',
		}
Esempio n. 14
0
	def test_update_po_success(self):
		data = {
			'name': 'changed_name',
			'guid': Dummies.get_or_create_po().guid
		}
		response = self.client.put(self.url, data = data, content_type = self.request_content_type)

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

		content = json.loads(response.content)

		self.assertIsInstance(content, dict, content)
		self.assertIn(self.key, content)
		self.assertEqual(content.get(self.key).get('name'), data.get('name'))
	def setUp(self):
		self.url = '/api/cmn/transaction/'
		self.request_content_type = 'application/json'
		self.client = Client()

		self.user = Dummies.get_or_create_user()
		self.po = Dummies.get_or_create_po()
		self.transaction_status_success = Dummies.get_or_create_transaction_status('success')
		self.transaction_status_success = Dummies.get_or_create_transaction_status('error')
		self.supplier = Dummies.get_or_create_supplier()
		self.expense_item = Dummies.get_or_create_expense_item()

		self.client.login(username = self.user.username, password = Dummies.get_password())
		self.key = 'transaction'

		self.new_transaction = {
			'date': int(time.time()) * 100,
			'supplier_id': self.supplier.guid,
			'payment_object_id': self.po.guid,
			'expense_items': []
		}
	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,
		}
	def setUp(self):
		self.category_level = Dummies.get_or_create_root_category_level()
Esempio n. 18
0
	def setUp(self):
		self.category = Dummies.get_or_create_root_category()
Esempio n. 19
0
	def setUp(self):
		"""
		Tests setups
		"""
		self.user = Dummies.get_or_create_user()