コード例 #1
0
 def test_a(self):
     """Test the correct legend name is returned when the key is a string."""
     label = Label()
     label.name = "neerslag"
     label.program_name = "precipitation"
     label.save()
     legend_info = LegendInfo()
     legend_info.retrieve_labels()
     (legend_name, label) = legend_info.retrieve("precipitation")
     self.assertEqual("neerslag", legend_name)
     label.delete()
コード例 #2
0
 def test_b(self):
     """Test the correct Label is returned when the key is a string."""
     label = Label()
     label.name = "neerslag"
     label.program_name = "precipitation"
     label.save()
     stored_label = Label.objects.get(name__iexact="neerslag")
     legend_info = LegendInfo()
     legend_info.retrieve_labels()
     (legend_name, label) = legend_info.retrieve("precipitation")
     self.assertEqual(stored_label.pk, label.pk)
     label.delete()
コード例 #3
0
    def test_c(self):
        """Test the correct legend name is returned when the key is an intake.

        An intake is implemented by a PumpingStation.

        """
        label = Label()
        label.name = "inlaat 1"
        label.program_name = "inlet1"
        label.save()
        intake = PumpingStation()
        intake.name = "dijklek"
        intake.label = label
        # Note that we do not save the intake to the database. To save a
        # PumpingStation, we need to create a whole tree of objects. But that
        # is not necessary as long as a LegendInfo does not query that part of
        # the database.
        legend_info = LegendInfo()
        legend_info.retrieve_labels()
        (legend_name, label) = legend_info.retrieve(intake)
        self.assertEqual("dijklek", legend_name)
        label.delete()