Created
October 13, 2015 19:55
-
-
Save mhrivnak/e354fb65b44648c0f373 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestRepoUpdate(unittest.TestCase): | |
@classmethod | |
def setUpClass(cls): | |
cls.data = StuntData() | |
cls.repo_id = cls.data.create_repo(repotype='yum') | |
# call repo update API here | |
@classmethod | |
def tearDownClass(cls): | |
cls.data.cleanup() | |
def test_response_200(self): | |
# assert stuff here | |
class StuntData(object): | |
def __init__(self): | |
self.cleanup_funcs = [] | |
def cleanup(self): | |
# pop from the end to do LIFO, since some pieces of data may depend on others | |
while len(self.cleanup_funcs) > 0: | |
self.cleanup_funcs.pop()() | |
def __del__(self): | |
if len(self.cleanup_funcs) > 0: | |
_logger.error('Someone forgot to clean up!') | |
def create_repo(self, repotype): | |
repo_id = uuid.uuid4() | |
# make api calls to create the corresponding repo | |
self.cleanup_funcs.append(functools.partial(self.delete_repo, repo_id)) | |
return repo_id | |
def delete_repo(self, repo_id): | |
# make API calls here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment