Пример #1
0
    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),
                        })
Пример #2
0
    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),
            })
Пример #3
0
    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")
Пример #4
0
    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")
Пример #5
0
 def __init__(self, d):
     """
     really its just a wrapped around an existing dict
     """
     self.store = d
     self.matcher = KeyMatcher.from_dict(d)
Пример #6
0
    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"))
Пример #7
0
 def test_key_matcher_get_7(self):
     matcher = KeyMatcher()
     matcher.set("*/paul", "test")
     self.assertEqual(matcher.get("any/thing/else/paul"), "test")
Пример #8
0
 def test_key_matcher_get_4(self):
     matcher = KeyMatcher()
     matcher.set("*/paul", "test")
     self.assertEqual(matcher.get("paul"), "test")
Пример #9
0
 def test_key_matcher_get_fail(self):
     matcher = KeyMatcher()
     matcher.set("paul", "test")
     self.assertEqual(matcher.get("pauls"), None)
Пример #10
0
 def __init__(self, d):
     """
     really its just a wrapped around an existing dict
     """
     self.store = d
     self.matcher = KeyMatcher.from_dict(d)
Пример #11
0
    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"))
Пример #12
0
 def test_key_matcher_get_7(self):
     matcher = KeyMatcher()
     matcher.set("*/paul", "test")
     self.assertEqual(matcher.get("any/thing/else/paul"), "test")
Пример #13
0
 def test_key_matcher_get_4(self):
     matcher = KeyMatcher()
     matcher.set("*/paul", "test")
     self.assertEqual(matcher.get("paul"), "test")
Пример #14
0
 def test_key_matcher_get_fail(self):
     matcher = KeyMatcher()
     matcher.set("paul", "test")
     self.assertEqual(matcher.get("pauls"), None)