コード例 #1
0
    def test_validate_delete_default_node_group_error(self):
        default_ng = objects.Cluster.get_default_group(self.cluster)

        with self.assertRaises(errors.CannotDelete) as err:
            NodeGroupValidator.validate_delete(data={}, instance=default_ng)

        self.assertEqual(err.exception.message,
                         'Default node group cannot be deleted.')
コード例 #2
0
    def test_validate_delete_default_node_group_error(self):
        default_ng = objects.Cluster.get_default_group(self.cluster)

        with self.assertRaises(errors.CannotDelete) as err:
            NodeGroupValidator.validate_delete(data={}, instance=default_ng)

        self.assertEqual(err.exception.message,
                         'Default node group cannot be deleted.')
コード例 #3
0
ファイル: test_node_groups.py プロジェクト: xglhjk6/fuel-web
    def test_validate_updating_cluster_id_not_allowed(self):
        ng = objects.Cluster.get_default_group(self.cluster)

        data = json.dumps({'cluster_id': -1, 'name': ng.name})
        with self.assertRaises(errors.NotAllowed) as err:
            NodeGroupValidator.validate_update(data, ng)

        self.assertEqual(
            err.exception.message,
            "Node group cannot be assigned to other cluster "
            "after creation.")
コード例 #4
0
ファイル: test_node_groups.py プロジェクト: xglhjk6/fuel-web
    def test_validate_create_node_group_with_default_flag_fail(self):
        data = json.dumps({
            'cluster_id': self.cluster['id'],
            'name': 'test',
            'is_default': True
        })
        with self.assertRaises(errors.NotAllowed) as err:
            NodeGroupValidator.validate(data)

        self.assertEqual(err.exception.message,
                         "Default node group is created only by Nailgun.")
コード例 #5
0
    def test_validate_updating_cluster_id_not_allowed(self):
        ng = objects.Cluster.get_default_group(self.cluster)

        data = json.dumps({'cluster_id': -1, 'name': ng.name})
        with self.assertRaises(errors.NotAllowed) as err:
            NodeGroupValidator.validate_update(data, ng)

        self.assertEqual(
            err.exception.message,
            "Node group cannot be assigned to other cluster "
            "after creation."
        )
コード例 #6
0
    def test_validate_create_node_group_with_default_flag_fail(self):
        data = json.dumps(
            {'cluster_id': self.cluster['id'],
             'name': 'test',
             'is_default': True}
        )
        with self.assertRaises(errors.NotAllowed) as err:
            NodeGroupValidator.validate(data)

        self.assertEqual(
            err.exception.message,
            "Default node group is created only by Nailgun."
        )
コード例 #7
0
    def test_delete_non_default_node_group_error(self):
        node_group = self.env.create_node_group(api=False,
                                                cluster_id=self.cluster.id)
        self.env.create_node(group_id=node_group.id)
        self.env.create_node(group_id=node_group.id,
                             status=consts.NODE_STATUSES.error)

        with self.assertRaises(errors.CannotDelete) as err:
            NodeGroupValidator.validate_delete(data={}, instance=node_group)

        self.assertEqual(err.exception.message,
                         'Node group can be deleted only when all its nodes '
                         'are in bootstrap state.')
コード例 #8
0
    def test_delete_non_default_node_group_error(self):
        node_group = self.env.create_node_group(api=False,
                                                cluster_id=self.cluster.id)
        self.env.create_node(group_id=node_group.id)
        self.env.create_node(group_id=node_group.id,
                             status=consts.NODE_STATUSES.error)

        with self.assertRaises(errors.CannotDelete) as err:
            NodeGroupValidator.validate_delete(data={}, instance=node_group)

        self.assertEqual(err.exception.message,
                         'Node group can be deleted only when all its nodes '
                         'are in bootstrap state.')
コード例 #9
0
ファイル: test_node_groups.py プロジェクト: xglhjk6/fuel-web
    def test_validate_updating_node_group_default_flag_not_allowed(self):
        ng = objects.Cluster.get_default_group(self.cluster)

        data = json.dumps({
            'cluster_id': self.cluster['id'],
            'name': ng.name,
            'is_default': not (ng.is_default)
        })
        with self.assertRaises(errors.NotAllowed) as err:
            NodeGroupValidator.validate_update(data, ng)

        self.assertEqual(err.exception.message,
                         "'default' flag for node group cannot be changed")
コード例 #10
0
    def test_validate_updating_node_group_default_flag_not_allowed(self):
        ng = objects.Cluster.get_default_group(self.cluster)

        data = json.dumps(
            {'cluster_id': self.cluster['id'],
             'name': ng.name,
             'is_default': not(ng.is_default)}
        )
        with self.assertRaises(errors.NotAllowed) as err:
            NodeGroupValidator.validate_update(data, ng)

        self.assertEqual(
            err.exception.message,
            "'default' flag for node group cannot be changed"
        )