from django.test import TestCase, RequestFactory

from ..models import Ambulances, Capability, Status

from ..serializers import StatusSerializer, AmbulancesSerializer

from django.test import Client

class CreateAmbulance(TestCase):

    def setUp(self):

        # Add status
        self.s1 = Status(name='Out of service')
        self.s1.save()
        self.s2 = Status(name='In service')
        self.s2.save()
        self.s3 = Status(name='Available')
        self.s3.save()
        
        # Add capability
        self.c1 = Capability(name='Basic')
        self.c1.save()
        self.c2 = Capability(name='Advanced')
        self.c2.save()
        self.c3 = Capability(name='Rescue')
        self.c3.save()
        
        # Add ambulances
        self.a1 = Ambulances(
            identifier='BC-179',
            comment='Maintenance due',
            capability=self.c1,
            status=self.s1)
        
        # Add ambulances
        self.a2 = Ambulances(
            identifier='BC-180',
            comment='Need painting',
            capability=self.c2,
            status=self.s3)

    def test_ambulances(self):

        serializer = StatusSerializer(self.s1)
        result = "\{'id': {}, 'name': '{}'\}".format(self.s1.pk, self.s1.name)
        self.assertEqual(serializer.data, result)

        serializer = StatusSerializer(self.s2)
        result = "{'id': {}, 'name': '{}'}".format(self.s2.pk, self.s2.name)
        self.assertEqual(serializer.data, result)

        serializer = StatusSerializer(self.s3)
        result = "{'id': {}, 'name': '{}'}".format(self.s3.pk, self.s3.name)
        self.assertEqual(serializer.data, result)
        

@@ -1146,118 +1146,42 @@
     
-serializer = StatusSerializer(self.s1)%0A        result = %22%5C%7B'id': %7B%7D, 'name': '%7B%7D'%5C%7D%22.format(
+for s in (self.s1, 
 self.s
-1.pk
+2
 , self.s
 1.na
@@ -1180,67 +1180,16 @@
 lf.s
-1.name)
+3):
 %0A    
-    self.assertEqual(serializer.data, result)%0A%0A
     
@@ -1223,22 +1223,16 @@
 alizer(s
-elf.s2
 )%0A      
@@ -1225,32 +1225,36 @@
 izer(s)%0A        
+    
 result = %22%7B'id':
@@ -1240,32 +1240,33 @@
      result = %22%7B
+%7B
 'id': %7B%7D, 'name'
@@ -1264,32 +1264,33 @@
 %7D, 'name': '%7B%7D'%7D
+%7D
 %22.format(self.s2
@@ -1287,208 +1287,25 @@
 at(s
-elf.s2.pk, self.s2.name)%0A        self.assertEqual(serializer.data, result)%0A%0A        serializer = StatusSerializer(self.s3)%0A        result = %22%7B'id': %7B%7D, 'name': '%7B%7D'%7D%22.format(self.s3.pk, self.s3.name)%0A
+.pk, s.name)%0A    
     
@@ -1350,16 +1350,17 @@
 result)%0A
+%0A
         

Test ambulances