diff options
-rwxr-xr-x | scripts/publish_to_snapshots.py | 15 | ||||
-rw-r--r-- | tests/test_publish_to_snapshots.py | 14 |
2 files changed, 14 insertions, 15 deletions
diff --git a/scripts/publish_to_snapshots.py b/scripts/publish_to_snapshots.py index c1d5662..90ac902 100755 --- a/scripts/publish_to_snapshots.py +++ b/scripts/publish_to_snapshots.py @@ -62,6 +62,11 @@ class PublisherArgumentException(Exception): pass +class BuildInfoException(Exception): + """BUILD-INFO.txt is absent.""" + pass + + class SnapshotsPublisher(object): # Files that need no sanitization even when publishing to staging. @@ -380,9 +385,8 @@ class SnapshotsPublisher(object): bi_dirs.append(path) if not bi_dirs: - return FAIL - - return PASS + raise BuildInfoException( + "BUILD-INFO.txt is not present for build being published.") def main(): @@ -404,10 +408,7 @@ def main(): if build_dir_path is None or target_dir_path is None: print "Problem with build/target path, move failed" return FAIL - ret = publisher.check_buildinfo(build_dir_path, target_dir_path) - if ret != PASS: - print "BUILD-INFO.txt is not present for build being published" - return FAIL + publisher.check_buildinfo(build_dir_path, target_dir_path) ret = publisher.move_artifacts(args, build_dir_path, target_dir_path) if ret != PASS: print "Move Failed" diff --git a/tests/test_publish_to_snapshots.py b/tests/test_publish_to_snapshots.py index 0f48800..b596cd6 100644 --- a/tests/test_publish_to_snapshots.py +++ b/tests/test_publish_to_snapshots.py @@ -11,8 +11,7 @@ from scripts.publish_to_snapshots import ( SnapshotsPublisher, setup_parser, product_dir_path, - FAIL, - PASS, + BuildInfoException, buildinfo ) @@ -746,8 +745,7 @@ class TestSnapshotsPublisher(TestCase): file = open(file_name, "w") file.close() - self.assertEqual(PASS, - self.publisher.check_buildinfo(build_path, www_path)) + self.assertIsNone(self.publisher.check_buildinfo(build_path, www_path)) def test_check_buildinfo_target_dir(self): self.publisher = SnapshotsPublisher() @@ -765,8 +763,7 @@ class TestSnapshotsPublisher(TestCase): file = open(file_name, "w") file.close() - self.assertEqual(PASS, - self.publisher.check_buildinfo(build_path, www_path)) + self.assertIsNone(self.publisher.check_buildinfo(build_path, www_path)) def test_check_buildinfo_no_file(self): self.publisher = SnapshotsPublisher() @@ -780,5 +777,6 @@ class TestSnapshotsPublisher(TestCase): www_path = os.path.join(self.target_path, build_dir) os.makedirs(www_path) - self.assertEqual(FAIL, - self.publisher.check_buildinfo(build_path, www_path)) + self.assertRaises( + BuildInfoException, + self.publisher.check_buildinfo, build_path, www_path) |