def test_nested_key_matcher(self): matcher = KeyMatcher() matcher.add_options(NESTED_OPTIONS, "piggy") self.assertEqual(matcher.options.keys(), [u'piggy/paint_coats', u'piggy']) self.assertEqual(matcher.get(u'piggy/paint_coats'), { u"type": VALUE_TYPE_NUMERIC_STEP, u"max": Decimal(6), u"min": Decimal(1), u"start": Decimal(1), u"step": Decimal(1), })
def test_nested_key_matcher(self): matcher = KeyMatcher() matcher.add_options(NESTED_OPTIONS, "piggy") self.assertEqual(matcher.options.keys(), [u'piggy/paint_coats', u'piggy']) self.assertEqual( matcher.get(u'piggy/paint_coats'), { u"type": VALUE_TYPE_NUMERIC_STEP, u"max": Decimal(6), u"min": Decimal(1), u"start": Decimal(1), u"step": Decimal(1), })
def test_finish_matcher(self): options_dict_b = { u"configuration": u"straight-tops", u"material-choices": { u"default": u"standard-laminate", u"name": u"Material", u"type": u"set::string", u"values": { u"name": u"Standard Laminate", u"options": { u"finish": u"$ref:/finishes/opendesk/standard-laminate" }, u"type": u"string", u"value": u"standard-laminate" } } } b_matcher = KeyMatcher.from_dict(options_dict_b) self.assertEqual(b_matcher.options["material-choices/finish"], "$ref:/finishes/opendesk/standard-laminate")
def __init__(self, d): """ really its just a wrapped around an existing dict """ self.store = d self.matcher = KeyMatcher.from_dict(d)
def test_key_matcher(self): matcher = KeyMatcher() self.assertTrue(matcher.validate("paul")) self.assertTrue(matcher.validate("piggy/paint_coats")) self.assertTrue(matcher.validate("paul/bum")) self.assertTrue(matcher.validate("paul/bum/head")) self.assertTrue(matcher.validate("*/paul")) self.assertFalse(matcher.validate("paul/")) self.assertFalse(matcher.validate("paul/bum/")) self.assertFalse(matcher.validate("/paul")) self.assertFalse(matcher.validate("paul/*/head")) self.assertFalse(matcher.validate("/*/paul"))
def test_key_matcher_get_7(self): matcher = KeyMatcher() matcher.set("*/paul", "test") self.assertEqual(matcher.get("any/thing/else/paul"), "test")
def test_key_matcher_get_4(self): matcher = KeyMatcher() matcher.set("*/paul", "test") self.assertEqual(matcher.get("paul"), "test")
def test_key_matcher_get_fail(self): matcher = KeyMatcher() matcher.set("paul", "test") self.assertEqual(matcher.get("pauls"), None)