示例#1
0
    def test_written_obs_sorted_chronologically_on_flush(self):
        self.undertest = mpc.MPCWriter(self.outputfile,
                                       auto_flush=False,
                                       include_comments=False)

        obs1 = mpc.Observation(
            provisional_name="A234567",
            discovery="*",
            note1="H",
            note2="N",
            date="2012 10 21.405160",
            ra="26.683336700",  # 01 46 44.001
            dec="29.220353200",  # +29 13 13.27
            mag="123.5",
            band="A",
            observatory_code="523")
        obs2 = mpc.Observation(
            provisional_name="A234567",
            discovery="*",
            note1="H",
            note2="N",
            date="2012 11 21.405160",
            ra="26.683336700",  # 01 46 44.001
            dec="29.220353200",  # +29 13 13.27
            mag="123.5",
            band="A",
            observatory_code="523")
        obs3 = mpc.Observation(
            provisional_name="A234567",
            discovery="*",
            note1="H",
            note2="N",
            date="2012 12 21.405160",
            ra="26.683336700",  # 01 46 44.001
            dec="29.220353200",  # +29 13 13.27
            mag="123.5",
            band="A",
            observatory_code="523")

        self.undertest.write(obs3)
        self.undertest.write(obs1)
        self.undertest.write(obs2)

        self.assertTrue(
            obs1 in self.undertest.get_chronological_buffered_observations())
        self.assertTrue(
            obs2 in self.undertest.get_chronological_buffered_observations())
        self.assertTrue(
            obs3 in self.undertest.get_chronological_buffered_observations())
示例#2
0
    def test_rejected_line_not_discovery_asterisk(self):

        self.undertest = mpc.MPCWriter(self.outputfile,
                                       auto_flush=False,
                                       include_comments=False)

        obs1 = mpc.Observation(
            provisional_name="A234567",
            date="2012 10 21.405160",
            ra="26.683336700",  # 01 46 44.001
            dec="29.220353200",  # +29 13 13.27
            observatory_code="523")
        obs1.null_observation = True

        obs2 = mpc.Observation(
            provisional_name="A234567",
            discovery=True,
            note1="H",
            note2="N",
            date="2012 11 21.405160",
            ra="26.683336700",  # 01 46 44.001
            dec="29.220353200",  # +29 13 13.27
            mag="23.5",
            band="A",
            observatory_code="523")

        self.undertest.write(obs2)

        self.undertest.write(obs1)

        self.undertest.flush()

        expected_first_line = (
            "!    A234567   2012 10 21.40516001 46 44.001+29 13 13.27                     523\n"
        )
        # "     A234567 HN2012 11 21.40516001 46 44.001+29 13 13.27         123.5A      523\n"
        expected_second_line = (
            "     A234567*HN2012 11 21.40516001 46 44.001+29 13 13.27         23.5 A      523\n"
        )

        self.assertEqual(self.read_outputfile(),
                         expected_first_line + expected_second_line)
示例#3
0
    def test_flush(self):
        self.undertest = mpc.MPCWriter(self.outputfile,
                                       auto_flush=False,
                                       include_comments=False)

        obs1 = mpc.Observation(
            provisional_name="A234567",
            discovery="*",
            note1="H",
            note2="N",
            date="2012 10 21.405160",
            ra="26.683336700",  # 01 46 44.001
            dec="29.220353200",  # +29 13 13.27
            mag="123.5",
            band="A",
            observatory_code="523")

        self.undertest.write(obs1)

        self.assertEqual(self.read_outputfile(), "")

        obs2 = mpc.Observation(
            date="2012 10 22.405160",
            ra="26.683336700",  # 01 46 44.001
            dec="29.220353200",  # +29 13 13.27
        )

        obs2.null_observation = True

        self.undertest.write(obs2)

        self.assertEqual(self.read_outputfile(), "")

        expected_mpcline = "     A234567*HN2012 10 21.40516001 46 44.001+29 13 13.27         123.5A      523\n"
        expected_reject_line = "!              2012 10 22.40516001 46 44.001+29 13 13.27                     568\n"

        self.undertest.flush()
        self.assertEqual(self.read_outputfile(),
                         expected_mpcline + expected_reject_line)
示例#4
0
    def test_flush(self):
        self.undertest = mpc.MPCWriter(self.outputfile, auto_flush=False)
        obs = Observation("1234567", "p", "00")
        reading = SourceReading(334.56, 884.22, 335.56, 885.22, 0, 0,
                                335.56, 885.22, obs)

        self.undertest.write_comment(reading, "Something fishy.")

        assert_that(self.read_outputfile(), equal_to(""))

        self.undertest.write_mpc_line("12345",
                                      "A234567",
                                      "*",
                                      "M",
                                      "N",
                                      "2012 10 21.405160",
                                      "26.683336700", # 01 46 44.001
                                      "29.220353200", # +29 13 13.27
                                      "123.5",
                                      "A",
                                      "523")

        assert_that(self.read_outputfile(), equal_to(""))

        self.undertest.write_rejection_line("2012 10 21.405160",
                                            "26.683336700", # 01 46 44.001
                                            "29.220353200", # +29 13 13.27
        )

        assert_that(self.read_outputfile(), equal_to(""))

        expected_comment = "# 1234567p00 334.56 884.22 Something fishy.\n"
        expected_mpcline = "12345A234567*MN2012 10 21.40516001 46 44.001+29 13 13.27         123.5A      523\n"
        expected_reject_line = "!              2012 10 21.40516001 46 44.001+29 13 13.27                        \n"

        self.undertest.flush()
        assert_that(self.read_outputfile(),
                    equal_to(expected_comment + expected_mpcline + expected_reject_line))
示例#5
0
 def setUp(self):
     self.outputfile = tempfile.TemporaryFile()
     self.undertest = mpc.MPCWriter(self.outputfile,
                                    auto_flush=True,
                                    include_comments=False)
示例#6
0
 def setUp(self):
     self.outputfile = tempfile.TemporaryFile()
     self.undertest = mpc.MPCWriter(self.outputfile)