Skip to content

Commit

Permalink
Add test for changes text.
Browse files Browse the repository at this point in the history
  • Loading branch information
allenh1 committed Feb 22, 2018
1 parent 56ddd8e commit ab839de
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions tests/test_generate_installers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import re

from superflore.exceptions import UnknownBuildType
from superflore.exceptions import UnknownLicense
from superflore.generate_installers import generate_installers
Expand All @@ -29,8 +31,8 @@ def _fail_if_p2os(overlay, pkg, distro, preserve_existing, collector):
"""Fail if it's a p2os package"""
collector.append(pkg)
if 'p2os' in pkg:
return False, pkg
return True, pkg
return False, True
return True, True


def _skip_if_p2os(overlay, pkg, distro, preserve_existing, collector):
Expand All @@ -41,6 +43,14 @@ def _skip_if_p2os(overlay, pkg, distro, preserve_existing, collector):
return True, pkg


def _create_if_p2os(overlay, pkg, distro, preserve_existing, collector):
"""Don't if the package is p2os"""
collector.append(pkg)
if 'p2os' in pkg:
return True, False
return True, True


def _raise_exceptions(overlay, pkg, distro, preserve_existing, collector):
"""Raise exceptions"""
collector.append(pkg)
Expand Down Expand Up @@ -107,3 +117,19 @@ def test_exceptions(self):
self.assertNotIn('k', p)
self.assertNotIn('l', p)
self.assertNotIn('b', p)

def test_changes(self):
"""Tests changes represented by generate installers"""
changes_re = '\*(([a-zA-Z]|\_|[0-9])+)\ [0-9]\.[0-9]\.[0-9]("-r"[0-9])?\*'
acc = list()
inst, broken, changes = generate_installers(
'lunar', None, _create_if_p2os, True, acc
)
found = False
for c in changes:
ret = re.search(changes_re, c)
if ret:
found = True
print(ret.groups())
self.assertIn('p2os', ret.group(0))
self.assertTrue(found)

0 comments on commit ab839de

Please # to comment.