from twisted.trial.unittest import TestCase
import vumi.blinkenlights.message20110818 as message
import time


class TestMessage(TestCase):

    def test_to_dict(self):
        now = time.time()
        datapoint = ("vumi.w1.a_metric", now, 1.5)
        msg = message.MetricMessage()
        msg.append(datapoint)
        self.assertEqual(msg.to_dict(), {
            'datapoints': [datapoint],
            })

    def test_from_dict(self):
        now = time.time()
        datapoint = ("vumi.w1.a_metric", now, 1.5)
        msgdict = {"datapoints": [datapoint]}
        msg = message.MetricMessage.from_dict(msgdict)
        self.assertEqual(msg._datapoints, [datapoint])

from twisted.trial.unittest import TestCase
import vumi.blinkenlights.message20110818 as message
import time


class TestMessage(TestCase):

    def test_to_dict(self):
        now = time.time()
        datapoint = ("vumi.w1.a_metric", now, 1.5)
        msg = message.MetricMessage()
        msg.append(datapoint)
        self.assertEqual(msg.to_dict(), {
            'datapoints': [datapoint],
            })

    def test_from_dict(self):
        now = time.time()
        datapoint = ("vumi.w1.a_metric", now, 1.5)
        msgdict = {"datapoints": [datapoint]}
        msg = message.MetricMessage.from_dict(msgdict)
        self.assertEqual(msg._datapoints, [datapoint])

    def test_extend(self):
        now = time.time()
        datapoint = ("vumi.w1.a_metric", now, 1.5)
        msg = message.MetricMessage()
        msg.extend([datapoint, datapoint, datapoint])
        self.assertEqual(msg._datapoints, [
            datapoint, datapoint, datapoint])

Add test for extend method.
Add test for extend method.

  from twisted.trial.unittest import TestCase
  import vumi.blinkenlights.message20110818 as message
  import time
  
  
  class TestMessage(TestCase):
  
      def test_to_dict(self):
          now = time.time()
          datapoint = ("vumi.w1.a_metric", now, 1.5)
          msg = message.MetricMessage()
          msg.append(datapoint)
          self.assertEqual(msg.to_dict(), {
              'datapoints': [datapoint],
              })
  
      def test_from_dict(self):
          now = time.time()
          datapoint = ("vumi.w1.a_metric", now, 1.5)
          msgdict = {"datapoints": [datapoint]}
          msg = message.MetricMessage.from_dict(msgdict)
          self.assertEqual(msg._datapoints, [datapoint])
  
+     def test_extend(self):
+         now = time.time()
+         datapoint = ("vumi.w1.a_metric", now, 1.5)
+         msg = message.MetricMessage()
+         msg.extend([datapoint, datapoint, datapoint])
+         self.assertEqual(msg._datapoints, [
+             datapoint, datapoint, datapoint])
+ 
Add test for extend method.
## Code Before:
from twisted.trial.unittest import TestCase
import vumi.blinkenlights.message20110818 as message
import time


class TestMessage(TestCase):

    def test_to_dict(self):
        now = time.time()
        datapoint = ("vumi.w1.a_metric", now, 1.5)
        msg = message.MetricMessage()
        msg.append(datapoint)
        self.assertEqual(msg.to_dict(), {
            'datapoints': [datapoint],
            })

    def test_from_dict(self):
        now = time.time()
        datapoint = ("vumi.w1.a_metric", now, 1.5)
        msgdict = {"datapoints": [datapoint]}
        msg = message.MetricMessage.from_dict(msgdict)
        self.assertEqual(msg._datapoints, [datapoint])

## Instruction:
Add test for extend method.
## Code After:
from twisted.trial.unittest import TestCase
import vumi.blinkenlights.message20110818 as message
import time


class TestMessage(TestCase):

    def test_to_dict(self):
        now = time.time()
        datapoint = ("vumi.w1.a_metric", now, 1.5)
        msg = message.MetricMessage()
        msg.append(datapoint)
        self.assertEqual(msg.to_dict(), {
            'datapoints': [datapoint],
            })

    def test_from_dict(self):
        now = time.time()
        datapoint = ("vumi.w1.a_metric", now, 1.5)
        msgdict = {"datapoints": [datapoint]}
        msg = message.MetricMessage.from_dict(msgdict)
        self.assertEqual(msg._datapoints, [datapoint])

    def test_extend(self):
        now = time.time()
        datapoint = ("vumi.w1.a_metric", now, 1.5)
        msg = message.MetricMessage()
        msg.extend([datapoint, datapoint, datapoint])
        self.assertEqual(msg._datapoints, [
            datapoint, datapoint, datapoint])
