Commit c5c17323 authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Add asserts to distributions

This adds asserts that ensure that the Chromes that are generated are
self-consistent and will correctly function.

Bug: 1142508
Change-Id: Ic827df20741b4d3255667957a64247c8f903efb9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2499343Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820935}
parent f7f4abdd
...@@ -209,6 +209,14 @@ class Distribution(object): ...@@ -209,6 +209,14 @@ class Distribution(object):
package_as_pkg: If True, then a .pkg file will be created containing package_as_pkg: If True, then a .pkg file will be created containing
the product. the product.
""" """
if channel_customize:
# Side-by-side channels must have a distinct names and creator
# codes, as well as keep their user data in separate locations.
assert channel
assert app_name_fragment
assert product_dirname
assert creator_code
self.channel = channel self.channel = channel
self.branding_code = branding_code self.branding_code = branding_code
self.app_name_fragment = app_name_fragment self.app_name_fragment = app_name_fragment
......
...@@ -95,7 +95,10 @@ class TestDistribution(unittest.TestCase): ...@@ -95,7 +95,10 @@ class TestDistribution(unittest.TestCase):
def test_channel_customize(self): def test_channel_customize(self):
base_config = TestConfig() base_config = TestConfig()
config = model.Distribution( config = model.Distribution(
channel='beta', app_name_fragment='Beta', channel='beta',
app_name_fragment='Beta',
product_dirname='beta',
creator_code='beta',
channel_customize=True).to_config(base_config) channel_customize=True).to_config(base_config)
self.assertEqual('App Product Beta', config.app_product) self.assertEqual('App Product Beta', config.app_product)
self.assertEqual(base_config.product, config.product) self.assertEqual(base_config.product, config.product)
...@@ -122,6 +125,8 @@ class TestDistribution(unittest.TestCase): ...@@ -122,6 +125,8 @@ class TestDistribution(unittest.TestCase):
channel='dev', channel='dev',
app_name_fragment='Dev', app_name_fragment='Dev',
packaging_name_fragment='Dev', packaging_name_fragment='Dev',
product_dirname='dev',
creator_code='dev ',
channel_customize=True) channel_customize=True)
config = dist.to_config(TestConfig()) config = dist.to_config(TestConfig())
self.assertEqual('App Product Dev', config.app_product) self.assertEqual('App Product Dev', config.app_product)
......
...@@ -39,6 +39,9 @@ class TestGetParts(unittest.TestCase): ...@@ -39,6 +39,9 @@ class TestGetParts(unittest.TestCase):
def test_get_parts_customize(self): def test_get_parts_customize(self):
config = model.Distribution( config = model.Distribution(
channel='canary', channel='canary',
app_name_fragment='Canary',
product_dirname='canary',
creator_code='cana',
channel_customize=True).to_config(test_config.TestConfig()) channel_customize=True).to_config(test_config.TestConfig())
all_parts = parts.get_parts(config) all_parts = parts.get_parts(config)
self.assertEqual('test.signing.bundle_id.canary', self.assertEqual('test.signing.bundle_id.canary',
......
...@@ -122,7 +122,9 @@ class TestPipelineHelpers(unittest.TestCase): ...@@ -122,7 +122,9 @@ class TestPipelineHelpers(unittest.TestCase):
dist = model.Distribution( dist = model.Distribution(
channel_customize=True, channel_customize=True,
channel='canary', channel='canary',
app_name_fragment='Canary') app_name_fragment='Canary',
product_dirname='canary',
creator_code='cana')
config = test_config.TestConfig() config = test_config.TestConfig()
dist_config = dist.to_config(config) dist_config = dist.to_config(config)
paths = self.paths.replace_work('/$W') paths = self.paths.replace_work('/$W')
...@@ -181,7 +183,9 @@ class TestPipelineHelpers(unittest.TestCase): ...@@ -181,7 +183,9 @@ class TestPipelineHelpers(unittest.TestCase):
channel_dist = model.Distribution( channel_dist = model.Distribution(
channel_customize=True, channel_customize=True,
channel='canary', channel='canary',
app_name_fragment='Canary') app_name_fragment='Canary',
product_dirname='canary',
creator_code='cana')
channel_dist_config = channel_dist.to_config(config) channel_dist_config = channel_dist.to_config(config)
paths = self.paths.replace_work('/$W') paths = self.paths.replace_work('/$W')
...@@ -264,7 +268,9 @@ class TestPipelineHelpers(unittest.TestCase): ...@@ -264,7 +268,9 @@ class TestPipelineHelpers(unittest.TestCase):
dist = model.Distribution( dist = model.Distribution(
channel_customize=True, channel_customize=True,
channel='canary', channel='canary',
app_name_fragment='Canary') app_name_fragment='Canary',
product_dirname='canary',
creator_code='cana')
paths = self.paths.replace_work('/$W') paths = self.paths.replace_work('/$W')
pipeline._staple_chrome(paths, dist.to_config(test_config.TestConfig())) pipeline._staple_chrome(paths, dist.to_config(test_config.TestConfig()))
...@@ -584,7 +590,9 @@ framework dir is 'App Product.app/Contents/Frameworks/Product Framework.framewor ...@@ -584,7 +590,9 @@ framework dir is 'App Product.app/Contents/Frameworks/Product Framework.framewor
dist = model.Distribution( dist = model.Distribution(
channel_customize=True, channel_customize=True,
channel='canary', channel='canary',
app_name_fragment='Canary') app_name_fragment='Canary',
product_dirname='canary',
creator_code='cana')
config = dist.to_config(test_config.TestConfig()) config = dist.to_config(test_config.TestConfig())
paths = self.paths.replace_work('/$W') paths = self.paths.replace_work('/$W')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment