コード例 #1
0
    def test_success(self):
        specs = [{'content_type_id' : 'foo', 'unit_id' : 'bar'}]
        ret = self.api.remove_bulk(specs)

        body = json.dumps(specs)
        self.api.server.POST.assert_called_once_with(self.api.DELETE_BULK_PATH,
        body)

        self.assertEqual(ret, self.api.server.POST.return_value)
コード例 #2
0
ファイル: content.py プロジェクト: ehelms/pulp
    def remove_bulk(self, specs):
        """
        Remove several orphaned content units.

        :param specs: list of dicts that include keys "content_type_id" and
                      "unit_id". Each dict matches one unit to be removed.
        :type specs:  list of dicts
        """
        expected_keys = set(('content_type_id', 'unit_id'))
        for spec in tuple(specs):
            if not isinstance(spec, dict):
                raise TypeError('members of "spec" must be dicts')
            if expected_keys != set(spec.keys()):
                raise ValueError('dict must include 2 keys: "content_type_id" and "unit_id"')

        body = json.dumps(specs)
        return self.server.POST(self.DELETE_BULK_PATH, body)
コード例 #3
0
ファイル: model.py プロジェクト: ehelms/pulp
    def to_json(self):
        """
        Serializes the repository metadata into its JSON representation.
        """

        # Assemble all of the modules in dictionary form
        module_dicts = [m.to_dict() for m in self.modules]

        # For each module, we only want a small subset of data that goes in the
        # repo metadata document
        limited_module_dicts = []
        included_fields = ('name', 'author', 'version', 'tag_list')
        for m in module_dicts:
            clean_module = dict([(k, v) for k, v in m.items() if k in included_fields])
            limited_module_dicts.append(clean_module)

        # Serialize the dictionaries into a single JSON document
        serialized = json.dumps(limited_module_dicts)

        return serialized