Beispiel #1
0
class PlaceTest(unittest.TestCase):
    def setUp(self):
        self.place = Place(label='testing place')
        
        if len(PlaceType.objects.all())==0:
            place_type = PlaceType(description='Matriz')
            place_type.save()
            document = TypeDocument(description='CPF')
            document.save()
            a = AddressType(description='Comercial')
            a.save()
            room_type = RoomType()
            room_type.description = 'sala test'
            room_type.save()
            plan = Plan()
            plan.name = 'Teste 1'
            plan.value = 324.00
            plan.duration = 1
            plan.staff_size = 1
            plan.save()
            p = PaymentType()
            p.id = 1
            p.name = 'Teste 1'
            p.save()
            p  = PaymentType()
            p.id = 4
            p.name = 'Teste 4'
            p.save()
            country = Country(name='test', nationality='testing')
            country.save()
            state = State(name='test', shortName='t', country=country)
            state.save()
            city = City(name='test', state=state)
            city.save()
        else:
            place_type = PlaceType.objects.get(description='Matriz')
        self.place.place_type = place_type
        phone_type = PhoneType(description='phone type test')
        phone_type.save()
        self.phone = Phone(area='23', phoneNumber='45679078', ext='4444',
                      phoneType=phone_type)
        self.phone.content_object = self.place
        addressType = AddressType(description='Home')
        addressType.save()
        address = Address()
        address.addressPrefix = 'Rua'
        address.addressLine1 = 'Rui Barbosa, 1234'
        address.addressLine2 = 'Anexo II - Sala 4'
        address.neighborhood = 'Centro'
        address.zipCode = '12345-123'
        address.addressType = AddressType.objects.get(pk=1)

        country = Country(name='test', nationality='testing')
        country.save()
        state = State(name='test', shortName='t', country=country)
        state.save()
        city = City(name='test', state=state)
        city.save()

        address.city = city
        address.content_object = self.place

        self.place.save()
        
        

    def testTypeReturnHoursWork(self):
        self.assertEquals(type(self.place.hours_work()), type([]))


    def testReturnHoursWork(self):
        self.assertEquals(self.place.hours_work(), [07, 00, 12.0])

    def testGetFisrtPhone(self):
        self.assertEquals(self.place.get_first_phone(), '')

    def testInvalidFirst(self):
        pass

    def testoccurrences(self):
        self.assertEquals(self.place.occurrences(),[])

    def testDefaultPlace(self):
        #get all places stored in the database and put them in a list
        #then compare the first (and probably only) stored-place
        #with self.place
        self.assertEquals(Place.objects.all()[0], self.place,
                          'place has not been appropriately saved')