Пример #1
0
    def testEncoderDefault(self):
        enc = twc.encoder
        enc.encode("")
        res = enc.default(twr.JSSymbol("X"))
        self.assert_(res.startswith("TW2Encoder_unescape_"))

        try:
            res = enc.default(None)
            self.assert_(False)
        except TypeError, te:
            self.assert_(str(te).endswith("is not JSON serializable"))
Пример #2
0
class MokshaTW2CPUUsageWidget(LiveAreaChartWidget):
    name = 'CPU Usage (with tw2.jit)'
    topic = 'moksha_jit_cpu_metrics'

    width='400px'
    height='300px'
    offset = 0
    showAggregates = False
    showLabels = False
    animate = False
    type = 'stacked'
    Tips = {
        'enable': True,
        'onShow' : res.JSSymbol(src="""
        (function(tip, elem) {
            tip.innerHTML = "<b>" + elem.name + "</b>: " + elem.value;
        })""")
    }

    container_options = { 'icon': 'chart.png', 'height' : 325 }
    data = {'labels': [], 'values': []}
Пример #3
0
 def testUnEscapeMarked(self):
     enc = twc.encoder
     data = dict(foo=twr.JSSymbol("foo"), bar=twr.JSSymbol("bar"))
     res = enc.unescape_marked(enc.encode(data))
     self.assert_("foo" in res, res)
     self.assert_("bar" in res, res)
Пример #4
0
 def testJSSymbol(self):
     """
     should set the src attribute
     """
     s = twr.JSSymbol("source")
     self.assert_(s.src == "source")