예제 #1
0
    def test_links_with_value(self):
        link = Link({'foo': 1, 'spam__egg': 2}, default=0)
        self.assertTrue('foo' in link)
        self.assertEqual(link['foo'], 1)
        self.assertFalse('spam' in link)
        self.assertEqual(link['spam'], 0)

        spamlink = link.get_deep_links('spam')
        self.assertTrue('egg' in spamlink)
        self.assertEqual(spamlink['bar'], 0)
        self.assertEqual(spamlink['egg'], 2)
예제 #2
0
    def test_links_with_value(self):
        link = Link({"foo": 1, "spam__egg": 2}, default=0)
        self.assertTrue("foo" in link)
        self.assertEqual(link["foo"], 1)
        self.assertFalse("spam" in link)
        self.assertEqual(link["spam"], 0)

        spamlink = link.get_deep_links("spam")
        self.assertTrue("egg" in spamlink)
        self.assertEqual(spamlink["bar"], 0)
        self.assertEqual(spamlink["egg"], 2)
예제 #3
0
    def test_nested_links(self):
        link = Link(("foo", "foo__bar", "spam__ALL"))
        self.assertTrue("foo" in link)
        self.assertFalse("spam" in link)
        self.assertFalse("egg" in link)

        foolink = link.get_deep_links("foo")
        self.assertTrue("bar" in foolink)
        self.assertFalse("egg" in foolink)

        spamlink = link.get_deep_links("spam")
        self.assertTrue("bar" in spamlink)
        self.assertTrue("egg" in spamlink)
예제 #4
0
    def test_nested_links(self):
        link = Link(('foo', 'foo__bar', 'spam__ALL'))
        self.assertTrue('foo' in link)
        self.assertFalse('spam' in link)
        self.assertFalse('egg' in link)

        foolink = link.get_deep_links('foo')
        self.assertTrue('bar' in foolink)
        self.assertFalse('egg' in foolink)

        spamlink = link.get_deep_links('spam')
        self.assertTrue('bar' in spamlink)
        self.assertTrue('egg' in spamlink)
예제 #5
0
    def test_always_true_link(self):
        link = Link(True)
        self.assertTrue("field" in link)
        self.assertTrue("any" in link)

        link = link.get_deep_links("field")
        self.assertTrue("field" in link)
        self.assertTrue("any" in link)

        link = Link(("ALL",))
        self.assertTrue("field" in link)
        self.assertTrue("any" in link)

        link = link.get_deep_links("field")
        self.assertTrue("field" in link)
        self.assertTrue("any" in link)
예제 #6
0
    def test_flat_link(self):
        link = Link(('foo', 'bar'))
        self.assertTrue('foo' in link)
        self.assertTrue('bar' in link)
        self.assertFalse('spam' in link)

        self.assertEqual(link['foo'], None)
        self.assertEqual(link['spam'], None)
예제 #7
0
    def test_always_true_link(self):
        link = Link(True)
        self.assertTrue('field' in link)
        self.assertTrue('any' in link)

        link = link.get_deep_links('field')
        self.assertTrue('field' in link)
        self.assertTrue('any' in link)

        link = Link(('ALL',))
        self.assertTrue('field' in link)
        self.assertTrue('any' in link)

        link = link.get_deep_links('field')
        self.assertTrue('field' in link)
        self.assertTrue('any' in link)
예제 #8
0
    def test_inherit_always_true_value(self):
        link = Link({"ALL": 1})
        self.assertEqual(link["foo"], 1)

        sublink = link.get_deep_links("foo")
        self.assertEqual(sublink["bar"], 1)
예제 #9
0
    def test_inherit_always_true_value(self):
        link = Link({'ALL': 1})
        self.assertEqual(link['foo'], 1)

        sublink = link.get_deep_links('foo')
        self.assertEqual(sublink['bar'], 1)