-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,445 additions
and
135 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#! /usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2015 Red Hat | ||
# Licensed under The MIT License (MIT) | ||
# http://opensource.org/licenses/MIT | ||
# | ||
import unittest | ||
import argparse | ||
|
||
""" | ||
Use this script either without arguments to run all tests: | ||
python client_test_run.py | ||
or with specific module/test to run only part of the test suite: | ||
python client_test_run.py pdc_client.tests.release.tests.ReleaseTestCase.test_list_all | ||
""" | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser('client_test_run.py') | ||
parser.add_argument('tests', metavar='TEST', nargs='*') | ||
options = parser.parse_args() | ||
loader = unittest.TestLoader() | ||
if options.tests: | ||
suite = loader.loadTestsFromNames(options.tests) | ||
else: | ||
suite = loader.discover('pdc_client/tests', top_level_dir='.') | ||
unittest.TextTestRunner().run(suite) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2015 Red Hat | ||
# Licensed under The MIT License (MIT) | ||
# http://opensource.org/licenses/MIT | ||
# | ||
|
||
|
||
import argparse | ||
import errno | ||
import logging | ||
import os | ||
|
||
|
||
PLUGIN_TEMPLATE = ''' | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2015 Red Hat | ||
# Licensed under The MIT License (MIT) | ||
# http://opensource.org/licenses/MIT | ||
# | ||
import json | ||
from pdc_client import plugin_helpers | ||
class {class_name}(plugin_helpers.PDCClientPlugin): | ||
def register(self): | ||
pass | ||
PLUGIN_CLASSES = [{class_name}] | ||
''' | ||
|
||
|
||
TEST_TEMPLATE = ''' | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2015 Red Hat | ||
# Licensed under The MIT License (MIT) | ||
# http://opensource.org/licenses/MIT | ||
# | ||
from pdc_client.test_helpers import CLITestCase | ||
from pdc_client.runner import Runner | ||
class {name}TestCase(CLITestCase): | ||
def setUp(self): | ||
self.runner = Runner() | ||
self.runner.setup() | ||
''' | ||
|
||
|
||
def write_file(name, contents): | ||
try: | ||
with open(name, 'wx') as f: | ||
f.write(contents) | ||
except IOError as err: | ||
if err.errno == errno.EEXIST: | ||
logging.warning('Not overwriting %s', name) | ||
else: | ||
logging.error('Unhandled exception', exc_info=err) | ||
else: | ||
logging.info('Created %s (%d bytes)', name, len(contents)) | ||
|
||
|
||
def create_plugin(name): | ||
filepath = os.path.join('pdc_client', 'plugins', name + '.py') | ||
class_name = '{}Plugin'.format(name.capitalize()) | ||
data = PLUGIN_TEMPLATE.format(class_name=class_name).lstrip() | ||
write_file(filepath, data) | ||
|
||
|
||
def create_tests(name): | ||
path = os.path.join('pdc_client', 'tests', name) | ||
try: | ||
os.makedirs(os.path.join(path, 'data')) | ||
logging.info('Created %s/', os.path.join(path, 'data')) | ||
except os.error: | ||
pass | ||
write_file(os.path.join(path, '__init__.py'), '') | ||
data = TEST_TEMPLATE.format(name=name.capitalize()).lstrip() | ||
write_file(os.path.join(path, 'tests.py'), data) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser('create-plugin.py') | ||
parser.add_argument('name', metavar='NAME') | ||
parser.add_argument('--skip-tests', action='store_true') | ||
parser.add_argument('--verbose', action='store_true') | ||
options = parser.parse_args() | ||
logging.basicConfig(level=logging.INFO if options.verbose else logging.WARNING, | ||
format='%(levelname)s: %(message)s') | ||
name = options.name | ||
create_plugin(name) | ||
if not options.skip_tests: | ||
create_tests(name) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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
File renamed without changes.
Empty file.
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
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
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
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
Oops, something went wrong.