Exemple #1
0
    def test_airmass_calculation(self):
        airmasses = get_airmasses_for_request_at_sites(self.request.as_dict)

        # Should be no data betwee 3:30AM and 18:30PM acording to pure rise set for this target, so verify that
        expected_null_range = (datetime(2016, 10, 1, 3, 30,
                                        0), datetime(2016, 10, 1, 18, 30, 0))

        for airmass_time in airmasses['airmass_data']['tst']['times']:
            atime = datetime.strptime(airmass_time, '%Y-%m-%dT%H:%M')
            if atime > expected_null_range[0] and atime < expected_null_range[
                    1]:
                self.fail("Should not get airmass ({}) within range {}".format(
                    atime, expected_null_range))
Exemple #2
0
 def airmass(self, request, pk=None):
     return Response(
         get_airmasses_for_request_at_sites(self.get_object().as_dict))
Exemple #3
0
 def post(self, request):
     serializer = RequestSerializer(data=request.data)
     if serializer.is_valid():
         return Response(get_airmasses_for_request_at_sites(serializer.validated_data))
     else:
         return Response(serializer.errors)
Exemple #4
0
    def test_airmass_calculation_empty(self):
        self.location.site = 'cpt'
        self.location.save()
        airmasses = get_airmasses_for_request_at_sites(self.request.as_dict)

        self.assertFalse(airmasses['airmass_data'])