def test_conflict_public_ip(self):
        ctx = self.mock_ctx('testconflictip')
        current_ctx.set(ctx=ctx)
        ctx.logger.info("BEGIN conflict public_ip test")

        ctx.logger.info("create public_ip")
        status_code = public_ip.create(ctx=ctx)
        ctx.logger.debug("status_code =" + str(status_code) )
        self.assertTrue(bool((status_code == 200) or (status_code == 201)))
        current_ctx.set(ctx=ctx)
        utils.wait_status(ctx, "public_ip",constants.SUCCEEDED, timeout=600)

        status_code = public_ip.create(ctx=ctx)
        ctx.logger.debug("status_code =" + str(status_code) )
        self.assertTrue(bool((status_code == 200) or (status_code == 201)))

        ctx.logger.info("delete public_ip")
        self.assertEqual(202, public_ip.delete(ctx=ctx))
        try:
            current_ctx.set(ctx=ctx)
            utils.wait_status(ctx, "public_ip","waiting for exception", timeout=600)
        except utils.WindowsAzureError:
            pass

        ctx.logger.info("delete conflict public_ip")
        self.assertEqual(204, public_ip.delete(ctx=ctx))
        
        ctx.logger.info("END conflict public_ip test")
    def test_delete_public_ip(self):
        ctx = self.mock_ctx('testdeleteip')
        current_ctx.set(ctx=ctx)
        ctx.logger.info("BEGIN public_ip delete test")

        ctx.logger.info("create public ip with deletable propertie set to False")
        ctx.node.properties[constants.DELETABLE_KEY] = False

        status_code = public_ip.create(ctx=ctx)
        ctx.logger.debug("status_code =" + str(status_code) )
        self.assertTrue(bool((status_code == 200) or (status_code == 201)))
        current_ctx.set(ctx=ctx)
        utils.wait_status(ctx, "public_ip",constants.SUCCEEDED, timeout=600)

        ctx.logger.info("not delete public ip")
        self.assertEqual(0, public_ip.delete(ctx=ctx))

        ctx.logger.info("Set deletable propertie to True")
        ctx.node.properties[constants.DELETABLE_KEY] = True

        ctx.logger.info("delete public ip")
        self.assertEqual(202, public_ip.delete(ctx=ctx))

        try:
            current_ctx.set(ctx=ctx)
            utils.wait_status(ctx, "public_ip","waiting for exception", timeout=600)
        except utils.WindowsAzureError:
            pass

        ctx.logger.info("END public_ip delete test")
    def setUpClass(self): 
        ctx = self.mock_ctx('init')
        ctx.logger.info("BEGIN test NIC number " + self.__random_id)
        ctx.logger.info("CREATE NIC\'s required resources")

        ctx.logger.info("CREATE ressource_group")
        current_ctx.set(ctx=ctx)
        resource_group.create(ctx=ctx)

        ctx.logger.info("CREATE public_ip")
        current_ctx.set(ctx=ctx)
        ctx.node.properties[constants.PUBLIC_IP_KEY] = "nic_public_ip_test" + self.__random_id
        public_ip.create(ctx=ctx)
        
        ctx.logger.info("CREATE network")
        current_ctx.set(ctx=ctx)
        ctx.node.properties[constants.VIRTUAL_NETWORK_ADDRESS_KEY] = "10.0.0.0/16"
        network.create(ctx=ctx)

        ctx.logger.info("CREATE subnet")
        current_ctx.set(ctx=ctx)
        ctx.node.properties[constants.SUBNET_ADDRESS_KEY] = "10.0.1.0/24"
        subnet.create(ctx=ctx)