def test_filter(self, where): Department.filter(max_results=25, start_position='1', Active=True) where.assert_called_once_with("Active = True", max_results=25, start_position='1', order_by='', qb=None)
def test_where_with_qb(self): with patch.object(self.qb_client, 'query') as query: Department.where("Active=True", start_position=1, max_results=10, qb=self.qb_client) self.assertTrue(query.called)
def test_all(self, where): Department.all() where.assert_called_once_with('', order_by='', max_results=100, start_position='', qb=None)
def test_update(self): department = Department.all(max_results=1, qb=self.qb_client)[0] unique_name = "Test Department {0}".format(datetime.now().strftime('%d%H%M%S')) department.Name = unique_name department.save(qb=self.qb_client) query_department = Department.get(department.Id, qb=self.qb_client) self.assertEqual(query_department.Name, unique_name)
def test_to_ref(self): department = Department() department.Name = "test" department.Id = 100 dept_ref = department.to_ref() self.assertEquals(dept_ref.name, "test") self.assertEquals(dept_ref.type, "Department") self.assertEquals(dept_ref.value, 100)
def test_save_update(self, update_object): department = Department() department.Id = 1 json = department.to_json() department.save(qb=self.qb_client) update_object.assert_called_once_with("Department", json)
def test_save_update_with_qb(self): with patch.object(self.qb_client, 'update_object') as update_object: department = Department() department.Id = 1 json = department.to_json() department.save(qb=self.qb_client) self.assertTrue(update_object.called)
def test_create(self): department = Department() department.Name = self.name department.save(qb=self.qb_client) query_department = Department.get(department.Id, qb=self.qb_client) self.assertEqual(department.Id, query_department.Id) self.assertEqual(query_department.Name, self.name)
def test_choose(self, where): Department.choose(['name1', 'name2'], field="Name") where.assert_called_once_with("Name in ('name1', 'name2')", qb=None)
def test_save_create_with_qb(self): with patch.object(self.qb_client, 'create_object') as create_object: department = Department() department.save(qb=self.qb_client) self.assertTrue(create_object.called)
def test_save_create(self, create_object): department = Department() department.save(qb=self.qb_client) create_object.assert_called_once_with("Department", department.to_json())
def test_get_with_qb(self): with patch.object(self.qb_client, 'get_single_object') as get_single_object: Department.get(1, qb=self.qb_client) self.assertTrue(get_single_object.called)
def test_get(self, get_single_object): Department.get(1) get_single_object.assert_called_once_with("Department", pk=1)
def test_all_with_qb(self): with patch.object(self.qb_client, 'query') as query: Department.all(qb=self.qb_client) self.assertTrue(query.called)
def test_valid_object_name(self): obj = Department() client = QuickBooks() result = client.isvalid_object_name(obj.qbo_object_name) self.assertTrue(result)
def test_query_with_qb(self): with patch.object(self.qb_client, 'query') as query: select = "SELECT * FROM Department WHERE Active=True" Department.query(select, qb=self.qb_client) self.assertTrue(query.called)
def test_query(self, query): select = "SELECT * FROM Department WHERE Active=True" Department.query(select) query.assert_called_once_with(select)
def test_filter_with_qb(self): with patch.object(self.qb_client, 'query') as query: Department.filter(Active=True, qb=self.qb_client) self.assertTrue(query.called)
def test_where(self, query): Department.where("Active=True", start_position=1, max_results=10) query.assert_called_once_with( "SELECT * FROM Department WHERE Active=True STARTPOSITION 1 MAXRESULTS 10", qb=None)
def test_choose_with_qb(self): with patch.object(self.qb_client, 'query') as query: Department.choose(['name1', 'name2'], field="Name", qb=self.qb_client) self.assertTrue(query.called)
def test_count(self, query): count = Department.count(where_clause="Active=True", qb=self.qb_client) query.assert_called_once_with( "SELECT COUNT(*) FROM Department WHERE Active=True")
def test_unicode(self): department = Department() department.Name = "test" self.assertEquals(str(department), "test")
def test_where_with_qb(self): with patch.object(self.qb_client, 'query') as query: Department.where("Active=True", 1, 10, qb=self.qb_client) self.assertTrue(query.called)