import pytest

from data import model
from endpoints.api.manifest import RepositoryManifest
from endpoints.api.test.shared import conduct_api_call
from endpoints.test.shared import client_with_identity
from test.fixtures import *

def test_repository_manifest(client):
  with client_with_identity('devtable', client) as cl:
    tags = model.tag.list_repository_tags('devtable', 'simple')
    digests = model.tag.get_tag_manifest_digests(tags)
    for tag in tags:
      manifest = digests[tag.id]
      params = {
        'repository': 'devtable/simple',
        'manifestref': manifest,
      }
      result = conduct_api_call(cl, RepositoryManifest, 'GET', params, None, 200).json
      assert result['digest'] == manifest
      assert result['manifest_data']
      assert result['image']