Beispiel #1
0
def test_get_configdocs_status():
    helper = ConfigdocsHelper(CTX)
    helper._get_revision_dict = lambda: REV_BUFFER_DICT
    helper._get_ordered_versions = lambda versions: ORDERED_VER
    helper._get_versions_name_id = lambda ordered_versions: REV_NAME_ID
    helper.deckhand.get_diff = (
        lambda old_revision_id, new_revision_id: DIFF_BUFFER_DICT)
    result = helper.get_configdocs_status()

    expected = [{
        "collection_name": 'chum',
        "base_version": 'committed',
        "base_revision": 3,
        "new_version": 'buffer',
        "new_revision": 5,
        "new_status": 'created',
        "base_status": 'not present'
    }, {
        "collection_name": 'mop',
        "base_version": 'committed',
        "base_revision": 3,
        "new_version": 'buffer',
        "new_revision": 5,
        "new_status": 'unmodified',
        "base_status": 'present'
    }, {
        "collection_name": 'slop',
        "base_version": 'committed',
        "base_revision": 3,
        "new_version": 'buffer',
        "new_revision": 5,
        "new_status": 'deleted',
        "base_status": 'present'
    }]

    assert expected == sorted(result, key=lambda x: x['collection_name'])
 def on_get(self, req, resp):
     """Returns a list of the configdocs and their statuses"""
     versions = req.params.get('versions') or None
     helper = ConfigdocsHelper(req.context)
     resp.body = self.to_json(helper.get_configdocs_status(versions))
     resp.status = falcon.HTTP_200