def __init__(self, product_id, name=None, version=None, architectures=None, provided_tags=None): # Initialize some defaults: if not name: name = product_id if not architectures: architectures = ["x86_64"] if not version: version = "1.0" # Tests sadly pass these in as a flat string. # TODO if provided_tags: provided_tags = parse_tags(provided_tags) Product.__init__(self, id=product_id, name=name, version=version, architectures=architectures, provided_tags=provided_tags)
def __init__(self, product_id, name=None, version=None, architectures=None, provided_tags=None): # Initialize some defaults: if not name: name = product_id if not architectures: architectures = ["x86_64"] if not version: version = "1.0" # Tests sadly pass these in as a flat string. # TODO if provided_tags: provided_tags = parse_tags(provided_tags) Product.__init__( self, id=product_id, name=name, version=version, architectures=architectures, provided_tags=provided_tags )
def product(self, version): return Product(id=self.product_info['id'], name=self.product_info['name'], version=version, architectures=self.product_info['arch'], provided_tags=self.product_info['tags'])
def test_brand_name_empty_string(self): p = Product(id="pid", name="pname", brand_name="") self.assertEqual(p.brand_name, "")
def test_brand_name_none(self): p = Product(id="pid", name="pname", brand_name=None) self.assertTrue(p.brand_name is None)
def test_brand_name(self): p = Product(id="pid", name="pname", brand_name="pbrand_name") self.assertTrue(p.brand_name == "pbrand_name")
def test_brand_type_empty_string(self): p = Product(id='pid', name='pname', brand_type="") self.assertEqual(p.brand_type, "")
def test_no_brand_type(self): p = Product(id="pid", name="pname") self.assertTrue(p.brand_type is None)
def test_none_arch(self): p = Product(id="pid", name="pname") self.assertTrue(p.architectures is not None) self.assertTrue(isinstance(p.architectures, list))
def test_arch_multi_valued(self): p = Product(id="pid", name="pname", architectures="i386,x86_64") self.assertEqual(2, len(p.architectures)) self.assertEqual("i386", p.architectures[0]) self.assertEqual("x86_64", p.architectures[1])