Esempio n. 1
0
 def test_west_turkana_occurrence_save_simple(self):
     """
     Test west_turkana_occurrence instance save method with the simplest possible attributes.
     """
     starting_record_count = Occurrence.objects.count()  # get current number of occurrence records
     # The simplest occurrence instance we can create needs six bits of data.
     # Using the instance creation and then save methods
     new_occurrence = Occurrence(id=1, item_type="Faunal", basis_of_record="HumanObservation",
                                 collecting_method="Surface Standard", field_number=datetime.now(),
                                 geom="POINT (40.8352906016 11.5303732536)")
     new_occurrence.save()
     now = datetime.now()
     self.assertEqual(Occurrence.objects.count(), starting_record_count+1)  # test that one record has been added
     self.assertEqual(new_occurrence.date_last_modified.day, now.day)  # test date last modified is correct
     self.assertEqual(new_occurrence.point_x(), 40.8352906016)
     self.assertEqual(new_occurrence.point_y(), 11.5303732536)
Esempio n. 2
0
    def test_west_turkana_save_method_invalid_item_type(self):
        """
        """
        starting_record_count = Occurrence.objects.count()
        new_occurrence = Occurrence()
        new_occurrence.item_type = "Fake"
        new_occurrence.basis_of_record = "HumanObservation"
        new_occurrence.collecting_method = "Surface Standard"
        new_occurrence.field_number = datetime.now()
        new_occurrence.geom = "POINT (40.8352906016 11.5303732536)"
        new_occurrence.save()

        now = datetime.now()
        self.assertEqual(Occurrence.objects.count(), starting_record_count+1)  # test that one record has been added
        self.assertEqual(new_occurrence.date_last_modified.day, now.day)  # test date last modified is correct
        self.assertEqual(new_occurrence.point_x(), 40.8352906016)
        self.assertEqual(new_occurrence.item_type, "Fake")