Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 def test_all(self, where):
     Department.all()
     where.assert_called_once_with('',
                                   order_by='',
                                   max_results=100,
                                   start_position='',
                                   qb=None)
Пример #4
0
    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)
Пример #5
0
    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)
Пример #6
0
    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)
Пример #7
0
    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)
Пример #8
0
    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)
Пример #9
0
 def test_choose(self, where):
     Department.choose(['name1', 'name2'], field="Name")
     where.assert_called_once_with("Name in ('name1', 'name2')", qb=None)
Пример #10
0
 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)
Пример #11
0
 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())
Пример #12
0
 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)
Пример #13
0
 def test_get(self, get_single_object):
     Department.get(1)
     get_single_object.assert_called_once_with("Department", pk=1)
Пример #14
0
 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)
Пример #15
0
    def test_valid_object_name(self):
        obj = Department()
        client = QuickBooks()
        result = client.isvalid_object_name(obj.qbo_object_name)

        self.assertTrue(result)
Пример #16
0
 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)
Пример #17
0
 def test_query(self, query):
     select = "SELECT * FROM Department WHERE Active=True"
     Department.query(select)
     query.assert_called_once_with(select)
Пример #18
0
 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)
Пример #19
0
 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)
Пример #20
0
 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)
Пример #21
0
 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")
Пример #22
0
    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)