コード例 #1
0
ファイル: test_offer.py プロジェクト: cudkowicz/esi-leap
    def test__verify_resource_permission_owner(self, mock_gro, mock_authorize,
                                               mock_is_resource_admin):

        OffersController._verify_resource_permission(
            owner_ctx.to_policy_values(), test_offer.to_dict())

        mock_gro.assert_called_once_with(test_offer.resource_type,
                                         test_offer.resource_uuid)
        mock_is_resource_admin.assert_called_once_with(test_offer.project_id)
        assert not mock_authorize.called
コード例 #2
0
ファイル: test_offer.py プロジェクト: DanNiESh/esi-leap
    def test__add_offer_availabilities(self, mock_get_availabilities):
        mock_get_availabilities.return_value = []

        o = offer.Offer(
            resource_type='test_node',
            resource_uuid='1234567890',
            name="o",
            status=statuses.AVAILABLE,
            start_time=start,
            end_time=end,
            project_id=owner_ctx.project_id
        )

        o_dict = OffersController._add_offer_availabilities(o)

        expected_offer_dict = {
            'resource_type': o.resource_type,
            'resource_uuid': o.resource_uuid,
            'name': o.name,
            'project_id': o.project_id,
            'start_time': o.start_time,
            'end_time': o.end_time,
            'status': o.status,
            'availabilities': [],
        }

        self.assertEqual(o_dict, expected_offer_dict)
コード例 #3
0
ファイル: test_offer.py プロジェクト: cudkowicz/esi-leap
    def test__verify_resource_permission_admin(self, mock_gro, mock_authorize,
                                               mock_is_resource_admin):

        bad_test_offer = offer.Offer(resource_type='test_node',
                                     resource_uuid=test_node_2._uuid,
                                     project_id=owner_ctx.project_id)

        assert OffersController._verify_resource_permission(
            admin_ctx.to_policy_values(), bad_test_offer.to_dict()) is None

        mock_gro.assert_called_once_with(bad_test_offer.resource_type,
                                         bad_test_offer.resource_uuid)
        mock_is_resource_admin.assert_called_once_with(
            bad_test_offer.project_id)
        mock_authorize.assert_called_once_with('esi_leap:offer:offer_admin',
                                               admin_ctx.to_policy_values(),
                                               admin_ctx.to_policy_values())