def test_address_lat_long(self): """ Tests Address if no latitude and longitude """ a = Address() a.city = City(id=0, name="trabalho a distancia", state=State(name="blah", code="BL")) self.assertEqual(a.latitude, 0.0) self.assertEqual(a.longitude, 0.0)
def create_address(self, zipcode="05432-001", addressline="Rua Hello World", addressnumber="123", addressline2="apt 1101", neighborhood="Copacabana"): state = State(name="Rio de Janeiro", code="RJ") city = City(name="Rio de Janeiro", state=state) return Address.objects.create(zipcode=zipcode, addressline=addressline, addressnumber=addressnumber, addressline2=addressline2, neighborhood=neighborhood, city=city)
def test_create_project_view_to_test_address_creation(self): """ Project to test address creation. """ factory = APIRequestFactory() project = { 'name': "Name", 'details': 'This needs to be big', 'description': 'This needs to be big', 'responsible': 'Marjor', 'phone': '123123', 'email': '*****@*****.**', 'skills': [1], 'causes': [2], 'work': { 'weekly_hours': 1, 'can_be_done_remotely': True }, 'address': { 'addressline': 'Rua Test', 'addressnumber': 234, 'neighborhood': 'Bairro', 'zipcode': '13230-455', 'city': { 'id': 9422 } } } s = State(name="sdfsdf") s.save() c = City(id=9422, name="sao paulo", state=s) c.save() request = factory.post("/create/project/", {'project': project}) u = User() u.save() n = Nonprofit(user=u) n.save() force_authenticate(request, user=u) response = views.create_project(request) self.assertEqual(response.status_code, status.HTTP_201_CREATED) p = Project.objects.all()[0] self.assertEqual(p.phone, "123123") self.assertEqual(p.name, "Name") self.assertTrue(p.address)
def create_state(self, name="Rio de Janeiro", code="RJ"): return State(name=name, code=code)
def create_city(self, name="Rio de Janeiro"): state = State(name="Rio de Janeiro", code="RJ") return City(name=name, state=state)