Exemple #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)
Exemple #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()
Exemple #3
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()
Exemple #4
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()
Exemple #5
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)
Exemple #6
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)
Exemple #7
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()
Exemple #8
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()