コード例 #1
0
    def test_get_service_list_with_filters(self):
        service1 = utils.create_test_service(
            id=1,
            name="SERVICE_ID_1",
            host="controller_1",
        )
        service2 = utils.create_test_service(
            id=2,
            name="SERVICE_ID_2",
            host="controller_2",
        )
        service3 = utils.create_test_service(
            id=3,
            name="SERVICE_ID_3",
            host="controller_3",
        )

        self.dbapi.soft_delete_service(service3['id'])

        res = self.dbapi.get_service_list(self.context,
                                          filters={'host': 'controller_1'})
        self.assertEqual([service1['id']], [r.id for r in res])

        res = self.dbapi.get_service_list(self.context,
                                          filters={'host': 'controller_3'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.get_service_list(self.context,
                                          filters={'host': 'controller_2'})
        self.assertEqual([service2['id']], [r.id for r in res])
コード例 #2
0
ファイル: test_service.py プロジェクト: akinsWin/watcher
    def _data_setup(self):
        service1_name = "SERVICE_ID_1"
        service2_name = "SERVICE_ID_2"
        service3_name = "SERVICE_ID_3"

        with freezegun.freeze_time(self.FAKE_TODAY):
            self.service1 = utils.create_test_service(
                id=1, name=service1_name, host="controller",
                last_seen_up=timeutils.parse_isotime("2016-09-22T08:32:05"))
        with freezegun.freeze_time(self.FAKE_OLD_DATE):
            self.service2 = utils.create_test_service(
                id=2, name=service2_name, host="controller",
                last_seen_up=timeutils.parse_isotime("2016-09-22T08:32:05"))
        with freezegun.freeze_time(self.FAKE_OLDER_DATE):
            self.service3 = utils.create_test_service(
                id=3, name=service3_name, host="controller",
                last_seen_up=timeutils.parse_isotime("2016-09-22T08:32:05"))
コード例 #3
0
 def test_get_service_list(self):
     ids = []
     for i in range(1, 4):
         service = utils.create_test_service(
             id=i,
             name="SERVICE_ID_%s" % i,
             host="controller_{0}".format(i))
         ids.append(service['id'])
     services = self.dbapi.get_service_list(self.context)
     service_ids = [s.id for s in services]
     self.assertEqual(sorted(ids), sorted(service_ids))
コード例 #4
0
ファイル: test_service.py プロジェクト: akinsWin/watcher
 def test_get_service_list(self):
     ids = []
     for i in range(1, 6):
         service = utils.create_test_service(
             id=i,
             name="SERVICE_ID_%s" % i,
             host="controller_{0}".format(i))
         ids.append(six.text_type(service['id']))
     res = self.dbapi.get_service_list(self.context)
     res_ids = [r.id for r in res]
     self.assertEqual(ids.sort(), res_ids.sort())
コード例 #5
0
 def test_create_service_already_exists(self):
     service_id = "STRATEGY_ID"
     utils.create_test_service(name=service_id)
     self.assertRaises(exception.ServiceAlreadyExists,
                       utils.create_test_service,
                       name=service_id)
コード例 #6
0
 def test_update_service(self):
     service = utils.create_test_service()
     res = self.dbapi.update_service(service['id'],
                                     {'host': 'controller_test'})
     self.assertEqual('controller_test', res.host)
コード例 #7
0
 def test_get_service_by_name(self):
     created_service = utils.create_test_service()
     service = self.dbapi.get_service_by_name(self.context,
                                              created_service['name'])
     self.assertEqual(service.name, created_service['name'])