Exemplo n.º 1
0
 def setUp(self):
     import datetime
     today = datetime.date.today()
     
     self.u = User(username='******')
     self.u.save()
     
     self.baron = Plane(tailnumber="N1234", type='BE-55')
     self.baron.save()
     
     self.seaplane = Plane(tailnumber="N5678", cat_class=3)
     self.seaplane.save()
     
     self.local_route = Route.from_string('kvta kvta')
     
     self.more50nm_route = Route.from_string('kvta kluk')
     self.no_land_more50nm_route = Route.from_string('kvta @kluk kvta')
     
     self.less50nm_route = Route.from_string('kvta kcmh')
     self.no_land_less50nm_route = Route.from_string('kvta @kcmh kvta')
     
     self.f = Flight(total=11.0,
                     pic=10.0,
                     date=today,
                     route=self.local_route)
Exemplo n.º 2
0
class PlacesTest(TestCase):
    def setUp(self):
        self.route = Route(name="Route 101")
        self.place1 = Place(name="Villa Venezuela")
        self.place2 = Place(name="Villa Libertad")

        self.route.save()
        self.place1.save()
        self.place2.save()

        self.route.places.add(self.place1, self.place2)

        self.route.save()

    def test_places_can_get_route(self):
        """docstring for test_places_can_get_route"""
        place1 = Place.objects.get(name="Villa Venezuela")
        place2 = Place.objects.get(name="Villa Libertad")

        self.assertEqual(place1.routes.all()[0], self.route)
        self.assertEqual(place2.routes.all()[0], self.route)

    def test_add_route_from_place(self):
        self.place1.add_route("Ruta 112")
        self.place1.save()

        self.assertEqual(self.place1.routes.count(), 2)

    def tearDown(self):
        Place.objects.all().delete()
        Route.objects.all().delete()
Exemplo n.º 3
0
    def setUp(self):
        import datetime
        today = datetime.date.today()

        self.u = User(username='******')
        self.u.save()

        self.baron = Plane(tailnumber="N1234", type='BE-55')
        self.baron.save()

        self.seaplane = Plane(tailnumber="N5678", cat_class=3)
        self.seaplane.save()

        self.local_route = Route.from_string('kvta kvta')

        self.more50nm_route = Route.from_string('kvta kluk')
        self.no_land_more50nm_route = Route.from_string('kvta @kluk kvta')

        self.less50nm_route = Route.from_string('kvta kcmh')
        self.no_land_less50nm_route = Route.from_string('kvta @kcmh kvta')

        self.f = Flight(total=11.0,
                        pic=10.0,
                        date=today,
                        route=self.local_route)
Exemplo n.º 4
0
def create_route(request):

    if request.method == 'POST':
        route_id = str(uuid.uuid4())
        route = Route(route_id=route_id, creation_date=datetime.date.today())
        route.save()

        return JsonResponse({'route_id': route.route_id}, status=201)
Exemplo n.º 5
0
    def add_route(self, name):
        """Adds a route from the model"""
        from route.models import Route

        if not Route.objects.filter(name=name).exists():
            route = Route(name=name)
            route.save()

            self.routes.add(route)
            self.save()
Exemplo n.º 6
0
    def test_get_route_length_successful(self):
        route = Route(route_id='d214623e-94da-4789-9c4d-20d1f90aa908',
                      creation_date=datetime.date.today(),
                      length=Decimal(20.25))
        route.save()

        response = self.client.get(
            '/route/d214623e-94da-4789-9c4d-20d1f90aa908/length/')
        response_details = response.json()

        assert 200 == response.status_code
        assert 20.25 == response_details['km']
Exemplo n.º 7
0
    def test_add_way_point_successful(self):
        route = Route(route_id='d214623e-94da-4789-9c4d-20d1f90aa907',
                      creation_date=datetime.date.today())
        route.save()

        response = self.client.post(
            '/route/d214623e-94da-4789-9c4d-20d1f90aa907/way_point/',
            json.dumps({
                'lat': 25.25,
                'lon': 23.23
            }),
            content_type="application/json")

        assert 201 == response.status_code
Exemplo n.º 8
0
class RoutesTest(TestCase):
    def setUp(self):
        self.route = Route(name="Route 101")
        self.place1 = Place(name="Villa Venezuela")
        self.place2 = Place(name="Villa Libertad")

        self.route.save()
        self.place1.save()
        self.place2.save()

        self.route.places.add(self.place1, self.place2)

        self.route.save()

    def test_routes_adds_places(self):
        """
        Creating a route and adding a place to it
        """
        # Getting the object from the database
        route = Route.objects.get(name="Route 101")

        self.assertEqual(route.places.count(), 2)

    def test_add_place_from_route(self):
        """
        Test the method add_place
        """
        self.route.add_place("14 De Septiembre")
        self.route.save()

        self.assertEqual(self.route.places.count(), 3)

    def tearDown(self):
        Place.objects.all().delete()
        Route.objects.all().delete()
Exemplo n.º 9
0
def single_route_kml(request, pk, f=False):
    """
    Return a KMZ file representing a single route. The route PK is passed in as
    opposed to a string representation of the route.
    
    If f=true, the pk is the
    pk of the flight the route is connected to (for one case in the logbook
    template where the flight pk is only available)
    """
    
    if f == "f":
        kwarg = {"flight__pk": pk}
    else:
        kwarg = {"pk": pk}
    
    # the actual route object
    route = Route.goof(**kwarg)
    
    #get distinct routebases to make icons with
    rbs = route.routebase_set.all()
    
    # convert routebases into locations
    l = Location.objects.filter(routebase__in=rbs).distinct()
    
    # convert back to dict and just the relevent bits
    r = dict(kml_rendered=route.kml_rendered,
             simple_rendered=route.simple_rendered)
    
    # make the folders
    f = RouteFolder(name="Route", qs=[r], style="#red_line")
    a = AirportFolder(name='Points', qs=l)

    return folders_to_kmz_response([f,a], add_icon=True)
Exemplo n.º 10
0
 def render_route(self):
     """
     Completely redo the route object, then update the flight's db record.
     """
     
     self.route = Route.from_string(self.route_string,
                                    user=self.user,
                                    date=self.date)
     self.save(no_badges=True)
Exemplo n.º 11
0
    def render_route(self):
        """
        Completely redo the route object, then update the flight's db record.
        """

        self.route = Route.from_string(self.route_string,
                                       user=self.user,
                                       date=self.date)
        self.save(no_badges=True)
Exemplo n.º 12
0
    def setUp(self):
        self.route = Route(name="Route 101")
        self.place1 = Place(name="Villa Venezuela")
        self.place2 = Place(name="Villa Libertad")

        self.route.save()
        self.place1.save()
        self.place2.save()

        self.route.places.add(self.place1, self.place2)

        self.route.save()
Exemplo n.º 13
0
 def setUp(self):
     self.p = Plane(tailnumber="N444444", cat_class=4, type="TYPE")
     self.p.save()
     
     self.u = User(username='******')
     self.u.save()
     
     self.f = Flight(plane=self.p,
                route=Route.from_string('mer-lga'),
                user=self.u,
                date='2009-01-05',
                total=10.0,
              )
     self.f.save()
Exemplo n.º 14
0
    def setUp(self):
        self.p = Plane(tailnumber="N444444", cat_class=4, type="TYPE")
        self.p.save()

        self.u = User(username='******')
        self.u.save()

        self.f = Flight(
            plane=self.p,
            route=Route.from_string('mer-lga'),
            user=self.u,
            date='2009-01-05',
            total=10.0,
        )
        self.f.save()