1 # Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # Copyright (C) 2013 Association of Universities for Research in Astronomy
19 # Redistribution and use in source and binary forms, with or without
20 # modification, are permitted provided that the following conditions are met:
22 # 1. Redistributions of source code must retain the above copyright
23 # notice, this list of conditions and the following disclaimer.
25 # 2. Redistributions in binary form must reproduce the above
26 # copyright notice, this list of conditions and the following
27 # disclaimer in the documentation and/or other materials provided
28 # with the distribution.
30 # 3. The name of AURA and its representatives may not be used to
31 # endorse or promote products derived from this software without
32 # specific prior written permission.
34 # THIS SOFTWARE IS PROVIDED BY AURA ``AS IS'' AND ANY EXPRESS OR IMPLIED
35 # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
36 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37 # DISCLAIMED. IN NO EVENT SHALL AURA BE LIABLE FOR ANY DIRECT, INDIRECT,
38 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
39 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
41 from testtools import content
43 from pbr.tests import base
46 class TestCommands(base.BaseTestCase):
47 def test_custom_build_py_command(self):
48 """Test custom build_py command.
50 Test that a custom subclass of the build_py command runs when listed in
51 the commands [global] option, rather than the normal build command.
54 stdout, stderr, return_code = self.run_setup('build_py')
55 self.addDetail('stdout', content.text_content(stdout))
56 self.addDetail('stderr', content.text_content(stderr))
57 self.assertIn('Running custom build_py command.', stdout)
58 self.assertEqual(0, return_code)
60 def test_custom_deb_version_py_command(self):
61 """Test custom deb_version command."""
62 stdout, stderr, return_code = self.run_setup('deb_version')
63 self.addDetail('stdout', content.text_content(stdout))
64 self.addDetail('stderr', content.text_content(stderr))
65 self.assertIn('Extracting deb version', stdout)
66 self.assertEqual(0, return_code)
68 def test_custom_rpm_version_py_command(self):
69 """Test custom rpm_version command."""
70 stdout, stderr, return_code = self.run_setup('rpm_version')
71 self.addDetail('stdout', content.text_content(stdout))
72 self.addDetail('stderr', content.text_content(stderr))
73 self.assertIn('Extracting rpm version', stdout)
74 self.assertEqual(0, return_code)
76 def test_freeze_command(self):
77 """Test that freeze output is sorted in a case-insensitive manner."""
78 stdout, stderr, return_code = self.run_pbr('freeze')
79 self.assertEqual(0, return_code)
81 for l in stdout.split('\n'):
82 pkgs.append(l.split('==')[0].lower())
83 pkgs_sort = sorted(pkgs[:])
84 self.assertEqual(pkgs_sort, pkgs)