コード例 #1
0
ファイル: tiip_test.py プロジェクト: whitelizard/pytiip
    def test007_setClientTime(self):
        # Correct (str, unicode, float, int, long, None)
        tiipMessage = TIIPMessage()
        tiipMessage.ct = str(self.clientTime)
        self.assertEquals(tiipMessage.ct, self.clientTime)
        tiipMessage.ct = self.clientTime
        self.assertEquals(tiipMessage.ct, self.clientTime)
        tiipMessage.ct = float(self.clientTime)
        self.assertEquals(tiipMessage.ct, self.clientTime)
        tiipMessage.ct = int(float(self.clientTime))
        self.assertEquals(tiipMessage.ct, repr(round(int(float(self.clientTime)), 3)))
        tiipMessage.ct = long(float(self.clientTime))
        self.assertEquals(tiipMessage.ct, repr(round(long(float(self.clientTime)), 3)))
        tiipMessage.ct = None
        self.assertEquals(tiipMessage.ct, None)

        # Incorrect
        tiipMessage = TIIPMessage()
        with self.assertRaises(ValueError):
            tiipMessage.ct = 'incorrectClientTimeStampString'
        with self.assertRaises(TypeError):
            tiipMessage.ts = dict()
コード例 #2
0
ファイル: tiip_test.py プロジェクト: whitelizard/pytiip
    def test006_setTimestamp(self):
        tiipMessage = TIIPMessage()

        # Correct (str, unicode, float, int, long)
        tiipMessage.ts = str(self.timestamp)
        self.assertEquals(tiipMessage.ts, self.timestamp)
        tiipMessage.ts = self.timestamp
        self.assertEquals(tiipMessage.ts, self.timestamp)
        tiipMessage.ts = float(self.timestamp)
        self.assertEquals(tiipMessage.ts, self.timestamp)
        tiipMessage.ts = int(float(self.timestamp))
        self.assertEquals(tiipMessage.ts, repr(round(int(float(self.timestamp)), 3)))
        tiipMessage.ts = long(float(self.timestamp))
        self.assertEquals(tiipMessage.ts, repr(round(long(float(self.timestamp)), 3)))

        # Incorrect
        tiipMessage = TIIPMessage()
        with self.assertRaises(TypeError):
            tiipMessage.ts = None
        with self.assertRaises(ValueError):
            tiipMessage.ts = 'incorrectTimestampString'
コード例 #3
0
    def test007_setClientTime(self):
        # Correct (str, unicode, float, int, long, None)
        tiipMessage = TIIPMessage()
        tiipMessage.ct = str(self.clientTime)
        self.assertEquals(tiipMessage.ct, self.clientTime)
        tiipMessage.ct = self.clientTime
        self.assertEquals(tiipMessage.ct, self.clientTime)
        tiipMessage.ct = float(self.clientTime)
        self.assertEquals(tiipMessage.ct, self.clientTime)
        tiipMessage.ct = int(float(self.clientTime))
        self.assertEquals(tiipMessage.ct,
                          repr(round(int(float(self.clientTime)), 3)))
        tiipMessage.ct = long(float(self.clientTime))
        self.assertEquals(tiipMessage.ct,
                          repr(round(long(float(self.clientTime)), 3)))
        tiipMessage.ct = None
        self.assertEquals(tiipMessage.ct, None)

        # Incorrect
        tiipMessage = TIIPMessage()
        with self.assertRaises(ValueError):
            tiipMessage.ct = 'incorrectClientTimeStampString'
        with self.assertRaises(TypeError):
            tiipMessage.ts = dict()
コード例 #4
0
    def test006_setTimestamp(self):
        tiipMessage = TIIPMessage()

        # Correct (str, unicode, float, int, long)
        tiipMessage.ts = str(self.timestamp)
        self.assertEquals(tiipMessage.ts, self.timestamp)
        tiipMessage.ts = self.timestamp
        self.assertEquals(tiipMessage.ts, self.timestamp)
        tiipMessage.ts = float(self.timestamp)
        self.assertEquals(tiipMessage.ts, self.timestamp)
        tiipMessage.ts = int(float(self.timestamp))
        self.assertEquals(tiipMessage.ts,
                          repr(round(int(float(self.timestamp)), 3)))
        tiipMessage.ts = long(float(self.timestamp))
        self.assertEquals(tiipMessage.ts,
                          repr(round(long(float(self.timestamp)), 3)))

        # Incorrect
        tiipMessage = TIIPMessage()
        with self.assertRaises(TypeError):
            tiipMessage.ts = None
        with self.assertRaises(ValueError):
            tiipMessage.ts = 'incorrectTimestampString'