def testValidateModel_InvalidValue(self): catalog = fake_catalogs.FakeIosCatalog() mgr = catalog_manager.IosCatalogManager(catalog) with self.assertRaises(exceptions.ModelNotFoundError) as ex_ctx: mgr.ValidateDimensionAndValue('model', 'iPear') self.assertIn("'iPear' is not a valid model", six.text_type(ex_ctx.exception))
def testValidateModels(self): catalog = fake_catalogs.FakeIosCatalog() mgr = catalog_manager.IosCatalogManager(catalog) model1 = mgr.ValidateDimensionAndValue('model', 'iPencil1') model2 = mgr.ValidateDimensionAndValue('model', 'iPen3') self.assertEqual(model1, 'iPencil1') self.assertEqual(model2, 'iPen3')
def testValidateVersionIds(self): catalog = fake_catalogs.FakeIosCatalog() mgr = catalog_manager.IosCatalogManager(catalog) ver1 = mgr.ValidateDimensionAndValue('version', '5.1') ver2 = mgr.ValidateDimensionAndValue('version', '7.2') self.assertEqual(ver1, '5.1') self.assertEqual(ver2, '7.2')
def testDimensionDefaults(self): catalog = fake_catalogs.FakeIosCatalog() mgr = catalog_manager.IosCatalogManager(catalog) self.assertEqual(mgr.GetDefaultModel(), 'iPen2') self.assertEqual(mgr.GetDefaultVersion(), '6.0') self.assertEqual(mgr.GetDefaultLocale(), 'ro') self.assertEqual(mgr.GetDefaultOrientation(), 'askew')
def testValidateXcodeVersion_InvalidValue(self): catalog = fake_catalogs.FakeIosCatalog() mgr = catalog_manager.IosCatalogManager(catalog) with self.assertRaises(exceptions.XcodeVersionNotFoundError) as ex_ctx: mgr.ValidateXcodeVersion('2.71828') self.assertIn("'2.71828' is not a supported Xcode version", six.text_type(ex_ctx.exception))
def testValidateDimension_InvalidDimensionName(self): catalog = fake_catalogs.FakeIosCatalog() mgr = catalog_manager.IosCatalogManager(catalog) with self.assertRaises(exceptions.InvalidDimensionNameError) as ex_ctx: mgr.ValidateDimensionAndValue('clone', 'iPear') self.assertIn("'clone' is not a valid dimension", six.text_type(ex_ctx.exception))
def testValidateOrientation_InvalidValue(self): catalog = fake_catalogs.FakeIosCatalog() mgr = catalog_manager.IosCatalogManager(catalog) with self.assertRaises(exceptions.OrientationNotFoundError) as ex_ctx: mgr.ValidateDimensionAndValue('orientation', 'slanted') self.assertIn("'slanted' is not a valid device orientation", six.text_type(ex_ctx.exception))
def testValidateLocale_InvalidValuel(self): catalog = fake_catalogs.FakeIosCatalog() mgr = catalog_manager.IosCatalogManager(catalog) with self.assertRaises(exceptions.LocaleNotFoundError) as ex_ctx: mgr.ValidateDimensionAndValue('locale', 'mtv') self.assertIn("'mtv' is not a valid locale", six.text_type(ex_ctx.exception))
def testValidateVersion_InvalidValue(self): catalog = fake_catalogs.FakeIosCatalog() mgr = catalog_manager.IosCatalogManager(catalog) with self.assertRaises(exceptions.VersionNotFoundError) as ex_ctx: mgr.ValidateDimensionAndValue('version', '99') self.assertIn("'99' is not a valid OS version", six.text_type(ex_ctx.exception))
def __init__(self, catalog_mgr=None, typed_arg_rules=None, shared_arg_rules=None): """Constructs an IosArgsManager for a single iOS test matrix. Args: catalog_mgr: an IosCatalogManager object. typed_arg_rules: a nested dict of dicts which are keyed first on the test type, then by whether args are required or optional, and what their default values are. If None, the default from TypedArgRules() is used. shared_arg_rules: a dict keyed by whether shared args are required or optional, and with a nested dict containing any default values for those shared args. If None, the default dict from SharedArgRules() is used. """ self._catalog_mgr = catalog_mgr or catalog_manager.IosCatalogManager() self._typed_arg_rules = typed_arg_rules or TypedArgRules() self._shared_arg_rules = shared_arg_rules or SharedArgRules()
def _IosArgManagerWithFakeCatalog(): cat_mgr = catalog_manager.IosCatalogManager(fake_catalogs.FakeIosCatalog()) return arg_manager.IosArgsManager(cat_mgr)
def testValidateOrientation(self): catalog = fake_catalogs.FakeIosCatalog() mgr = catalog_manager.IosCatalogManager(catalog) o1 = mgr.ValidateDimensionAndValue('orientation', 'askew') self.assertEqual(o1, 'askew')
def testValidateLocales(self): catalog = fake_catalogs.FakeIosCatalog() mgr = catalog_manager.IosCatalogManager(catalog) l1 = mgr.ValidateDimensionAndValue('locale', 'ro') self.assertEqual(l1, 'ro')
def testOrientationDefaultIsMissing(self): empty_catalog = fake_catalogs.EmptyIosCatalog() mgr = catalog_manager.IosCatalogManager(empty_catalog) with self.assertRaises(exceptions.DefaultDimensionNotFoundError) as ex_ctx: mgr.GetDefaultOrientation() self.assertIn('orientation', six.text_type(ex_ctx.exception))