Exemple #1
0
    def test_get(self):
        c = Converter("pants", conv_val, conv_item)

        ct = ConversionTable([c, ("shirt", conv_val, conv_item, True)])

        assert ct.get("belt") is None
        assert ct.get("pants") is c
Exemple #2
0
    def test_duplicate(self):
        c1 = Converter("pants", conv_val, conv_item)
        c2 = Converter("pants", conv_val, conv_item)
        c3 = Converter("shirt", conv_val, conv_item)

        ct = ConversionTable([c1, c2, c3])

        assert ct.get('pants') is c1
        l = ct.get_all('pants')
        assert l[0] is c1
        assert l[1] is c2

        ct.delete('pants')
        l = ct.get_all('pants')
        assert not l
        assert len(ct) == 1
        assert ct[0] is c3
Exemple #3
0
 def test_init_simple(self):
     c = Converter("pants", conv_val, conv_item)
     ct = ConversionTable([c])
     assert ct[0] is c
Exemple #4
0
 def test_repr(self):
     c = Converter("pants", conv_val, conv_item)
     assert repr(c) == "<Converter('pants')>"
Exemple #5
0
 def test_missing(self):
     c = Converter("pants", conv_val, conv_item, True)
     ct = ConversionTable([c])
     with self.assertRaises(ValueError):
         ct.convert({'shirt':42}) == {'shirt':42}
Exemple #6
0
 def test_generic(self):
     c = Converter("pants", conv_val, conv_item)
     ct = ConversionTable([c])
     assert ct.convert({'shirt':42}) == {'shirt':42}