示例#1
0
def heartbeat_packets(start=default_start_dt,
                      interval=timedelta(minutes=15),
                      n_packets=24,
                      role=vp.definitions.roles.test):
    """
    Create Voevents with varying ivorns and values of ``Who.Date``.

    Args:
        start(datetime.datetime): Start time.
        end(datetime.datetime): End time (non-inclusive).
        interval(datetime.timedelta): Heartbeat interval.
    Returns:
        packets: A list of VOEvent packets.
    """
    packets = []
    for ts in packetgen.timerange(start,start+n_packets*interval,interval):
        packets.append(packetgen.create_test_packet(testpacket_identity,
                                                    author_date=ts,
                                                    role=role))


    # NB Whitespacing of loaded (parsed) vs custom-built VOEvents is different:
    # http://lxml.de/FAQ.html#why-doesn-t-the-pretty-print-option-reformat-my-xml-output
    # So, to enable exact ``dumps`` matching (for equality testing)
    # we take the fake voevents on a save/load round-trip before we return
    packets = [ vp.loads(vp.dumps(v)) for v in packets]

    return packets
示例#2
0
def heartbeat_packets(start=default_start_dt,
                      interval=timedelta(minutes=15),
                      n_packets=24,
                      role=vp.definitions.roles.test):
    """
    Create Voevents with varying ivorns and values of ``Who.Date``.

    Args:
        start(datetime.datetime): Start time.
        end(datetime.datetime): End time (non-inclusive).
        interval(datetime.timedelta): Heartbeat interval.
    Returns:
        packets: A list of VOEvent packets.
    """
    packets = []
    for ts in packetgen.timerange(start, start + n_packets * interval,
                                  interval):
        packets.append(
            packetgen.create_test_packet(testpacket_identity,
                                         author_date=ts,
                                         role=role))

    # NB Whitespacing of loaded (parsed) vs custom-built VOEvents is different:
    # http://lxml.de/FAQ.html#why-doesn-t-the-pretty-print-option-reformat-my-xml-output
    # So, to enable exact ``dumps`` matching (for equality testing)
    # we take the fake voevents on a save/load round-trip before we return
    packets = [vp.loads(vp.dumps(v)) for v in packets]

    return packets
 def test_timerange(self):
     n_interval_added = 5
     times = [t for t in
              packetgen.timerange(self.start,
                                  self.start+self.interval*n_interval_added,
                                  self.interval)]
     self.assertEqual(n_interval_added, len(times))
     self.assertEqual(self.start, times[0])
 def test_timerange(self):
     n_interval_added = 5
     times = [
         t for t in packetgen.timerange(
             self.start, self.start +
             self.interval * n_interval_added, self.interval)
     ]
     self.assertEqual(n_interval_added, len(times))
     self.assertEqual(self.start, times[0])