Skip to content

Commit

Permalink
Rework the testcases to address cleaning of repositories
Browse files Browse the repository at this point in the history
Signed-off-by: Akashdeep Dhar <[email protected]>
  • Loading branch information
gridhead committed Mar 5, 2024
1 parent 6fd2538 commit 3c60906
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 72 deletions.
36 changes: 36 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
"""


from os import environ as envr

import pytest
from gitlab import Gitlab
from requests import Session

from pagure_exporter.conf import standard


def wipe_cookies():
def before_record_response(response):
response["headers"]["Set-Cookie"] = ""
Expand All @@ -30,3 +39,30 @@ def before_record_response(response):

def pytest_recording_configure(config, vcr):
vcr.before_record_response = wipe_cookies()


@pytest.fixture(scope="function")
def wipe_issues():
"""
Clean all existing issue tickets before running the issue creation related tests
"""

gobj = Gitlab(
url="https://gitlab.com",
private_token=envr['TEST_GKEY'],
timeout=30,
retry_transient_errors=True,
session=Session()
)
gpro = gobj.projects.get(id=envr["TEST_DEST"])

# There are a maximum of 4 issue tickets at https://pagure.io/protop2g-test-srce/issues
# Change this variable if the issue tickets are created or deleted from there
qant = 4

for indx in range(1, qant+1):
try:
gpro.issues.delete(str(indx))
standard.logger.info(f"Issue #{indx} was deleted")
except Exception as expt:
standard.logger.info(f"Issue #{indx} could not be deleted due to {expt}")
Loading

0 comments on commit 3c60906

Please sign in to comment.