Esempio n. 1
0
    def test_get_all(self):
        srv1 = {
            'share_network_id': '1',
            'host': 'host1',
            'status': constants.STATUS_ACTIVE,
        }
        srv2 = {
            'share_network_id': '1',
            'host': 'host1',
            'status': constants.STATUS_ERROR,
        }
        srv3 = {
            'share_network_id': '2',
            'host': 'host2',
            'status': constants.STATUS_ACTIVE,
        }
        servers = db_api.share_server_get_all(self.ctxt)
        self.assertEqual(len(servers), 0)

        to_delete = db_utils.create_share_server(**srv1)
        db_utils.create_share_server(**srv2)
        db_utils.create_share_server(**srv3)

        servers = db_api.share_server_get_all(self.ctxt)
        self.assertEqual(len(servers), 3)

        db_api.share_server_delete(self.ctxt, to_delete['id'])
        servers = db_api.share_server_get_all(self.ctxt)
        self.assertEqual(len(servers), 2)
Esempio n. 2
0
    def test_delete_with_details(self):
        server = db_utils.create_share_server(backend_details={
            'value1': '1',
            'value2': '2',
        })

        num_records = len(db_api.share_server_get_all(self.ctxt))
        db_api.share_server_delete(self.ctxt, server['id'])
        self.assertEqual(len(db_api.share_server_get_all(self.ctxt)),
                         num_records - 1)
Esempio n. 3
0
 def test_delete(self):
     server = db_utils.create_share_server()
     num_records = len(db_api.share_server_get_all(self.ctxt))
     db_api.share_server_delete(self.ctxt, server['id'])
     self.assertEqual(len(db_api.share_server_get_all(self.ctxt)),
                      num_records - 1)