Skip to content

Commit

Permalink
WIP: Add tests for pulp#726
Browse files Browse the repository at this point in the history
  • Loading branch information
Kersom committed Feb 22, 2018
1 parent 728932a commit 18e4783
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pulp_smash/tests/pulp3/constants.py
Expand Up @@ -5,6 +5,8 @@

BASE_PATH = '/api/v3/'

ARTIFACTS_PATH = urljoin(BASE_PATH, 'artifacts/')

BASE_IMPORTER_PATH = urljoin(BASE_PATH, 'importers/')

BASE_PUBLISHER_PATH = urljoin(BASE_PATH, 'publishers/')
Expand Down
31 changes: 31 additions & 0 deletions pulp_smash/tests/pulp3/file/api_v3/test_artifacts.py
@@ -0,0 +1,31 @@
# coding=utf-8
"""Tests that perform actions over Artifacts."""
from random import choice
import unittest
import os
import sys
from requests.exceptions import HTTPError
from io import BytesIO

from pulp_smash import api, config, selectors, utils
from pulp_smash.constants import FILE_URL
from pulp_smash.tests.pulp3.constants import ARTIFACTS_PATH
from pulp_smash.tests.pulp3.pulpcore.utils import set_up_module as setUpModule # noqa pylint:disable=unused-import
from pulp_smash.tests.pulp3.utils import clean_artifacts, get_auth


class FileUploadTestCase(unittest.TestCase, utils.SmokeTest):
"""Create an Artifact by uploading a file."""

def test_all(self):
"""Create an Artifact by uploading a file."""
cfg = config.get_config()
client = api.Client(cfg, api.json_handler)
file = utils.http_get(FILE_URL)
files = {'file': file}
# rv = client.post('/api/v3/artifacts/', files=files)

# artifacts = client.get('api/v3/content/file/')
clean_artifacts()

# Clean content first
11 changes: 11 additions & 0 deletions pulp_smash/tests/pulp3/utils.py
Expand Up @@ -11,6 +11,7 @@

from pulp_smash import api, config, selectors
from pulp_smash.tests.pulp3.constants import (
ARTIFACTS_PATH,
FILE_IMPORTER_PATH,
JWT_PATH,
STATUS_PATH,
Expand Down Expand Up @@ -218,3 +219,13 @@ def read_repo_content(repo):
return (api
.Client(config.get_config(), api.json_handler)
.get(urljoin(get_latest_repo_version(repo), 'content/')))


def clean_artifacts(cfg=None):
"""Clean artifacts present in pulp."""
if cfg is None:
cfg = config.get_config()
client = api.Client(cfg, api.echo_handler)
artifacts = client.get(ARTIFACTS_PATH)['results']
for artifact in artifacts:
client.delete(artifact['_href'])

0 comments on commit 18e4783

Please sign in to comment.