def test_get_row_by_time_nothing_found(self):
     """Test get_row_by_time with a big enough timestamp."""
     txlogs = [self.factory.make_transaction_log() for i in range(2)]
     tstamp = txlogs[-1].timestamp + timedelta(seconds=1)
     txid, newtstamp = utils.get_row_by_time(tstamp)
     self.assertEqual(txid, None)
     self.assertEqual(newtstamp, None)
示例#2
0
 def test_get_row_by_time_nothing_found(self):
     """Test get_row_by_time with a big enough timestamp."""
     txlogs = [self.factory.make_transaction_log() for i in range(2)]
     tstamp = txlogs[-1].timestamp + timedelta(seconds=1)
     txid, newtstamp = utils.get_row_by_time(tstamp)
     self.assertEqual(txid, None)
     self.assertEqual(newtstamp, None)
 def test_get_row_by_time_with_data(self):
     """Test get_row_by_time function when data is present."""
     ts = now()
     txlogs = [
         self.factory.make_transaction_log(timestamp=ts + timedelta(i, 0))
         for i in range(5)]
     tstamp = txlogs[2].timestamp
     txid, newtstamp = utils.get_row_by_time(tstamp)
     self.assertEqual(txid, txlogs[2].id)
     self.assertEqual(newtstamp, tstamp)
示例#4
0
 def test_get_row_by_time_with_data(self):
     """Test get_row_by_time function when data is present."""
     ts = now()
     txlogs = [
         self.factory.make_transaction_log(timestamp=ts + timedelta(i, 0))
         for i in range(5)
     ]
     tstamp = txlogs[2].timestamp
     txid, newtstamp = utils.get_row_by_time(tstamp)
     self.assertEqual(txid, txlogs[2].id)
     self.assertEqual(newtstamp, tstamp)
    def test_get_row_by_time_timestamp_twice(self):
        """Test get_row_by_time having two lines with same timestamp."""
        ts = now()
        txlogs = [
            self.factory.make_transaction_log(timestamp=ts + timedelta(i, 0))
            for i in range(5)]
        # put the timestamp of [3] into [1], the function should return the
        # id of [1]
        tstamp = txlogs[1].timestamp = txlogs[3].timestamp
        txlogs[1].save()

        txid, newtstamp = utils.get_row_by_time(tstamp)
        self.assertEqual(txid, txlogs[1].id)
        self.assertEqual(newtstamp, tstamp)
示例#6
0
    def test_get_row_by_time_timestamp_twice(self):
        """Test get_row_by_time having two lines with same timestamp."""
        ts = now()
        txlogs = [
            self.factory.make_transaction_log(timestamp=ts + timedelta(i, 0))
            for i in range(5)
        ]
        # put the timestamp of [3] into [1], the function should return the
        # id of [1]
        tstamp = txlogs[1].timestamp = txlogs[3].timestamp
        txlogs[1].save()

        txid, newtstamp = utils.get_row_by_time(tstamp)
        self.assertEqual(txid, txlogs[1].id)
        self.assertEqual(newtstamp, tstamp)
    def test_get_row_by_time_not_exact(self):
        """Test get_row_by_time not giving an exact timestamp."""
        ts = now()
        txlogs = [
            self.factory.make_transaction_log(timestamp=ts + timedelta(i, 0))
            for i in range(5)]

        # get a timestamp in the middle of [2] and [3], the function should
        # return the id of [3]
        tx2, tx3 = txlogs[2:4]
        delta = (txlogs[3].timestamp - txlogs[2].timestamp) / 2
        tstamp = txlogs[2].timestamp + delta

        txid, newtstamp = utils.get_row_by_time(tstamp)
        self.assertEqual(txid, txlogs[3].id)
        self.assertEqual(newtstamp, txlogs[3].timestamp)
示例#8
0
    def test_get_row_by_time_not_exact(self):
        """Test get_row_by_time not giving an exact timestamp."""
        ts = now()
        txlogs = [
            self.factory.make_transaction_log(timestamp=ts + timedelta(i, 0))
            for i in range(5)
        ]

        # get a timestamp in the middle of [2] and [3], the function should
        # return the id of [3]
        tx2, tx3 = txlogs[2:4]
        delta = (txlogs[3].timestamp - txlogs[2].timestamp) / 2
        tstamp = txlogs[2].timestamp + delta

        txid, newtstamp = utils.get_row_by_time(tstamp)
        self.assertEqual(txid, txlogs[3].id)
        self.assertEqual(newtstamp, txlogs[3].timestamp)
 def test_get_row_by_time_with_no_data(self):
     """Test the get_row_by_time function when no data is present."""
     txid, _ = utils.get_row_by_time(now())
     self.assertEqual(txid, None)
示例#10
0
 def test_get_row_by_time_with_no_data(self):
     """Test the get_row_by_time function when no data is present."""
     txid, _ = utils.get_row_by_time(now())
     self.assertEqual(txid, None)