From c405aadfb20c097a0d30d3c8784ecae06fcaf26a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 10 2012 21:18:44 +0000 Subject: Add test for empty arguments - Make sure when we run the command with no arguments we get the right error message --- diff --git a/test/test_R2rpm.py b/test/test_R2rpm.py index 134941f..92eefe4 100644 --- a/test/test_R2rpm.py +++ b/test/test_R2rpm.py @@ -45,6 +45,7 @@ import urllib2 sys.path.insert(0, os.path.abspath('../')) from r2spec.r2spec_obj import R2rpm, setup_parser +from r2spec import R2specError BASE_URL = 'https://fedorahosted.org/releases/F/e/FedoraReview/' R_SRC = 'Rdummypkg_1.0.tar.gz' @@ -88,6 +89,16 @@ class R2rpmtests(unittest.TestCase): """ Clean up the environnment, ran after every tests. """ clean_directory() + def test_r2rpm_empty_arguments(self): + """ Test R2rpm with no arguments """ + parser = setup_parser('R2rpm') + arg = parser.parse_args() + try: + R2rpm().main(arg) + except R2specError, err: + self.assertEqual('Not enough argument given, see -h/--help', + err.value) + def test_r2rpm_url(self): """ Test R2rpm using an url direct to the sources """ parser = setup_parser('R2rpm') diff --git a/test/test_R2spec.py b/test/test_R2spec.py index 89212b8..9a52fba 100644 --- a/test/test_R2spec.py +++ b/test/test_R2spec.py @@ -46,6 +46,7 @@ import urllib2 sys.path.insert(0, os.path.abspath('../')) from r2spec.r2spec_obj import R2spec, setup_parser +from r2spec import R2specError BASE_URL = 'https://fedorahosted.org/releases/F/e/FedoraReview/' R_SRC = 'Rdummypkg_1.0.tar.gz' @@ -89,6 +90,16 @@ class R2spectests(unittest.TestCase): """ Clean up the environnment, ran after every tests. """ clean_directory() + def test_r2spec_empty_arguments(self): + """ Test R2spec with no arguments """ + parser = setup_parser('R2spec') + arg = parser.parse_args() + try: + R2spec().main(arg) + except R2specError, err: + self.assertEqual('Not enough argument given, see -h/--help', + err.value) + def test_r2spec_url(self): """ Test R2spec using an url direct to the sources """ parser = setup_parser('R2spec')