def test_simple_result_set_as_dict(self):
        """
        Try the first result set with a single record from dict.
        """
        rs = ResultSet(self._get_result_set_file("record_set_files/test_data_1.txt.result.yml"))

        # Test the happy path
        base_timestamp = 3583861263.0
        particle_a = CtdpfParserDataParticle("10.5914,  4.1870,  161.06,   2693.0",
                                             internal_timestamp=base_timestamp, new_sequence=True).generate_dict()
        particle_b = CtdpfParserDataParticle("10.5915,  4.1871,  161.07,   2693.1",
                                             internal_timestamp=base_timestamp+1).generate_dict()

        self.assertTrue(rs.verify([particle_a, particle_b]))
        self.assertIsNone(rs.report())

        # test record count mismatch
        self.assertFalse(rs.verify([particle_a]))
        self.assertIsNotNone(rs.report())

        # test out of order record
        self.assertFalse(rs.verify([particle_b, particle_a]))
        self.assertIsNotNone(rs.report())

        # test bad data record
        self.assertFalse(rs.verify([particle_a, particle_a]))
        self.assertIsNotNone(rs.report())
    def test_simple_result_set_as_dict(self):
        """
        Try the first result set with a single record from dict.
        """
        rs = ResultSet(
            self._get_result_set_file(
                "record_set_files/test_data_1.txt.result.yml"))

        # Test the happy path
        base_timestamp = 3583861263.0
        particle_a = CtdpfParserDataParticle(
            "10.5914,  4.1870,  161.06,   2693.0",
            internal_timestamp=base_timestamp,
            new_sequence=True).generate_dict()
        particle_b = CtdpfParserDataParticle(
            "10.5915,  4.1871,  161.07,   2693.1",
            internal_timestamp=base_timestamp + 1).generate_dict()

        self.assertTrue(rs.verify([particle_a, particle_b]))
        self.assertIsNone(rs.report())

        # test record count mismatch
        self.assertFalse(rs.verify([particle_a]))
        self.assertIsNotNone(rs.report())

        # test out of order record
        self.assertFalse(rs.verify([particle_b, particle_a]))
        self.assertIsNotNone(rs.report())

        # test bad data record
        self.assertFalse(rs.verify([particle_a, particle_a]))
        self.assertIsNotNone(rs.report())
    def test_round(self):
        rs = ResultSet(self._get_result_set_file("record_set_files/test_data_2.txt.result.yml"))

        # Test the happy path
        base_timestamp = 3583861263.0
        particle_a = CtdpfParserDataParticle("10.5914,  4.1870,  161.06,   2693.0",
                                             internal_timestamp=base_timestamp, new_sequence=True).generate_dict()

        self.assertTrue(rs.verify([particle_a]))
        self.assertIsNone(rs.report())
    def test_simple_result_set(self):
        """
        Try the first result set with a single record.
        """
        rs = ResultSet(
            self._get_result_set_file(
                "record_set_files/test_data_1.txt.result.yml"))

        # Test the happy path
        base_timestamp = 3583861263.0
        particle_a = CtdpfParserDataParticle(
            "10.5914,  4.1870,  161.06,   2693.0",
            internal_timestamp=base_timestamp,
            new_sequence=True)
        particle_b = CtdpfParserDataParticle(
            "10.5915,  4.1871,  161.07,   2693.1",
            internal_timestamp=base_timestamp + 1)

        self.assertTrue(rs.verify([particle_a, particle_b]))
        self.assertIsNone(rs.report())

        # test record count mismatch
        self.assertFalse(rs.verify([particle_a]))
        self.assertIsNotNone(rs.report())

        # test out of order record
        self.assertFalse(rs.verify([particle_b, particle_a]))
        self.assertIsNotNone(rs.report())

        # test bad data record
        self.assertFalse(rs.verify([particle_a, particle_a]))
        self.assertIsNotNone(rs.report())

        # multiple data types in result
        self.assertFalse(rs.verify([particle_a, 'foo']))
        self.assertIsNotNone(rs.report())

        # stream name mismatch
        particle_a._data_particle_type = 'foo'
        particle_b._data_particle_type = 'foo'
        self.assertFalse(rs.verify([particle_a, particle_b]))
        self.assertIsNotNone(rs.report())

        # internal timestamp mismatch
        particle_a = CtdpfParserDataParticle(
            "10.5914,  4.1870,  161.06,   2693.0",
            internal_timestamp=base_timestamp + 1,
            new_sequence=True)
        particle_b = CtdpfParserDataParticle(
            "10.5915,  4.1871,  161.07,   2693.1",
            internal_timestamp=base_timestamp + 2)
        self.assertFalse(rs.verify([particle_a, particle_a]))
        self.assertIsNotNone(rs.report())
示例#5
0
    def test_simple_result_set(self):
        """
        Try the first result set with a single record.
        """
        rs = ResultSet(self._get_result_set_file("record_set_files/test_data_1.txt.result.yml"))

        # Test the happy path
        base_timestamp = 3583886463.0
        particle_a = CtdpfParserDataParticle(
            "10.5914,  4.1870,  161.06,   2693.0", internal_timestamp=base_timestamp, new_sequence=True
        )
        particle_b = CtdpfParserDataParticle(
            "10.5915,  4.1871,  161.07,   2693.1", internal_timestamp=base_timestamp + 1
        )

        self.assertTrue(rs.verify([particle_a, particle_b]))
        self.assertIsNone(rs.report())

        # test record count mismatch
        self.assertFalse(rs.verify([particle_a]))
        self.assertIsNotNone(rs.report())

        # test out of order record
        self.assertFalse(rs.verify([particle_b, particle_a]))
        self.assertIsNotNone(rs.report())

        # test bad data record
        self.assertFalse(rs.verify([particle_a, particle_a]))
        self.assertIsNotNone(rs.report())

        # multiple data types in result
        self.assertFalse(rs.verify([particle_a, "foo"]))
        self.assertIsNotNone(rs.report())

        # stream name mismatch
        particle_a._data_particle_type = "foo"
        particle_b._data_particle_type = "foo"
        self.assertFalse(rs.verify([particle_a, particle_b]))
        self.assertIsNotNone(rs.report())

        # internal timestamp mismatch
        particle_a = CtdpfParserDataParticle(
            "10.5914,  4.1870,  161.06,   2693.0", internal_timestamp=base_timestamp + 1, new_sequence=True
        )
        particle_b = CtdpfParserDataParticle(
            "10.5915,  4.1871,  161.07,   2693.1", internal_timestamp=base_timestamp + 2
        )
        self.assertFalse(rs.verify([particle_a, particle_a]))
        self.assertIsNotNone(rs.report())