def setUp(self): # color schemes with all different names self.burg = styling.burg(bins=4) self.burgYl = styling.burgYl(bins=4) self.redOr = styling.redOr(bins=4) self.orYel = styling.orYel(bins=4) self.peach = styling.peach(bins=4) self.pinkYl = styling.pinkYl(bins=4) self.mint = styling.mint(bins=4) self.bluGrn = styling.bluGrn(bins=4) self.darkMint = styling.darkMint(bins=4) self.emrld = styling.emrld(bins=4) self.bluYl = styling.bluYl(bins=4) self.teal = styling.teal(bins=4) self.tealGrn = styling.tealGrn(bins=4) self.purp = styling.purp(bins=4) self.purpOr = styling.purpOr(bins=4) self.sunset = styling.sunset(bins=4) self.magenta = styling.magenta(bins=4) self.sunsetDark = styling.sunsetDark(bins=4) self.brwnYl = styling.brwnYl(bins=4) self.armyRose = styling.armyRose(bins=4) self.fall = styling.fall(bins=4) self.geyser = styling.geyser(bins=4) self.temps = styling.temps(bins=4) self.tealRose = styling.tealRose(bins=4) self.tropic = styling.tropic(bins=4) self.earth = styling.earth(bins=4) self.antique = styling.antique(bins=4) self.bold = styling.bold(bins=4) self.pastel = styling.pastel(bins=4) self.prism = styling.prism(bins=4) self.safe = styling.safe(bins=4) self.vivid = styling.vivid(bins=4)
def test_querylayer_colors(self): """layer.QueryLayer color options tests""" # no color options passed basic = QueryLayer(self.query) self.assertEqual(basic.color, None) # check valid dict color options dict_colors = [{'column': 'mandrill', 'scheme': styling.armyRose(7)}, {'column': 'mercxx', 'scheme': {'bin_method': 'equal', 'bins': 7, 'name': 'Temps'}}, {'column': 'elephant', 'scheme': styling.redOr(10, bin_method='jenks')}] dict_colors_ans = ['mandrill', 'mercxx', 'elephant'] dict_colors_scheme = [{'name': 'ArmyRose', 'bins': 7, 'bin_method': 'quantiles'}, {'name': 'Temps', 'bins': 7, 'bin_method': 'equal'}, {'name': 'RedOr', 'bins': 10, 'bin_method': 'jenks'}] for idx, val in enumerate(dict_colors): qlayer = QueryLayer(self.query, color=val) self.assertEqual(qlayer.color, dict_colors_ans[idx]) self.assertEqual(qlayer.scheme, dict_colors_scheme[idx]) # check valid string color options str_colors = ['#FF0000', 'aliceblue', 'cookie_monster'] str_colors_ans = ['#FF0000', 'aliceblue', 'cookie_monster'] str_scheme_ans = [None, None, styling.mint(5)] for idx, color in enumerate(str_colors): qlayer = QueryLayer(self.query, color=color) print(qlayer.color) self.assertEqual(qlayer.color, str_colors_ans[idx]) self.assertEqual(qlayer.scheme, str_scheme_ans[idx]) # Exception testing # color column cannot be a geometry column with self.assertRaises(ValueError, msg='color clumn cannot be a geometry column'): QueryLayer(self.query, color='the_geom') # color dict must have a 'column' key with self.assertRaises(ValueError, msg='color dict must have a `column` key'): QueryLayer(self.query, color={'scheme': styling.vivid(10)})
def test_querylayer_colors(self): """layer.QueryLayer color options tests""" # no color options passed basic = QueryLayer(self.query) self.assertEqual(basic.color, None) # check valid dict color options dict_colors = [{ 'column': 'mandrill', 'scheme': styling.armyRose(7) }, { 'column': 'mercxx', 'scheme': { 'bin_method': 'equal', 'bins': 7, 'name': 'Temps' } }, { 'column': 'elephant', 'scheme': styling.redOr(10, bin_method='jenks') }] dict_colors_ans = ['mandrill', 'mercxx', 'elephant'] dict_colors_scheme = [{ 'name': 'ArmyRose', 'bins': 7, 'bin_method': 'quantiles' }, { 'name': 'Temps', 'bins': 7, 'bin_method': 'equal' }, { 'name': 'RedOr', 'bins': 10, 'bin_method': 'jenks' }] for idx, val in enumerate(dict_colors): qlayer = QueryLayer(self.query, color=val) self.assertEqual(qlayer.color, dict_colors_ans[idx]) self.assertEqual(qlayer.scheme, dict_colors_scheme[idx]) # check valid string color options str_colors = ('#FF0000', 'aliceblue', 'cookie_monster', 'big_bird') str_colors_ans = ('#FF0000', 'aliceblue', 'cookie_monster', 'big_bird') str_scheme_ans = (None, None, styling.mint(5), styling.antique(10)) for idx, color in enumerate(str_colors): qlayer = QueryLayer(self.query, color=color) qlayer.geom_type = 'point' if color == 'cookie_monster': qlayer.style_cols[color] = 'number' qlayer._setup([BaseMap(), qlayer], 1) # pylint: disable=protected-access elif color == 'big_bird': qlayer.style_cols[color] = 'string' qlayer._setup([BaseMap(), qlayer], 1) # pylint: disable=protected-access self.assertEqual(qlayer.color, str_colors_ans[idx]) self.assertEqual(qlayer.scheme, str_scheme_ans[idx]) with self.assertRaises(ValueError, msg='styling value cannot be a date'): qlayer = QueryLayer(self.query, color='datetime_column') qlayer.style_cols['datetime_column'] = 'date' qlayer._setup([BaseMap(), qlayer], 1) # pylint: disable=protected-access # Exception testing # color column cannot be a geometry column with self.assertRaises(ValueError, msg='color clumn cannot be a geometry column'): QueryLayer(self.query, color='the_geom') # color dict must have a 'column' key with self.assertRaises(ValueError, msg='color dict must have a `column` key'): QueryLayer(self.query, color={'scheme': styling.vivid(10)})