Exemple #1
0
  def test_create_project_view_to_test_address_creation(self):
    """
    Project to test address creation.
    """

    skill = Skill(name="Programming")
    skill.save()
    cause = Cause(name="Atados")
    cause.save()

    factory = APIRequestFactory()
    project = {
      'name': "Name",
      'details': 'This needs to be big',
      'description': 'This needs to be big',
      'responsible': 'Marjor',
      'phone': '11987456321',
      'email': '*****@*****.**',
      'skills': [{'id': 1}],
      'causes': [{'id': 1}],
      'work': {
        'weekly_hours': 1,
        'can_be_done_remotely': True
      },
      'address': {
        'addr': {
          'formatted_address': 'R. Capote Valente, 701, São Paulo'
        },
        'typed_address2': 'Complemento'
      }
    }


    s = State(name="sao paulo")
    s.save()
    c = City(id=9422, name="sao paulo", state=s)
    c.save()
    request = factory.post("/create/project/", {'project': json.dumps(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, "11987456321")
    self.assertEqual(p.name, "Name")
    self.assertTrue(p.googleaddress)
    self.assertEqual(p.googleaddress.typed_address, u"R. Capote Valente, 701, São Paulo")
    self.assertEqual(p.googleaddress.typed_address2, u"Complemento")
Exemple #2
0
 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)
Exemple #3
0
 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)
Exemple #4
0
  def test_create_volunteer_with_address_view(self):
    """
    Ensure we can create a new volunteer with address
    """
    s = State(name="User state")
    s.save()
    c = City(id=990, name="User city", state=s)
    c.save()

    factory = APIRequestFactory()
    request = factory.post("/create/volunteer/", {"slug": self.slug, "email": self.email, "password": self.password, 'address': {'addr': {'formatted_address': 'R. Capote Valente, 701, São Paulo'}, 'typed_address2': 'Complemento'}})
    response = views.create_volunteer(request)
    self.assertEqual(response.data, {'detail': 'Volunteer succesfully created.'})
    self.assertEqual(response.status_code, status.HTTP_201_CREATED)
    user = User.objects.get(email=self.email)
    volunteer = user.volunteer
    self.assertEqual(volunteer.user.email, user.email)
    self.assertEqual(user.googleaddress.typed_address, u"R. Capote Valente, 701, São Paulo")
    self.assertEqual(user.googleaddress.typed_address2, u"Complemento")
Exemple #5
0
 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)
Exemple #6
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)
Exemple #7
0
 def create_state(self, name="Rio de Janeiro", code="RJ"):
     return State(name=name, code=code)
Exemple #8
0
 def create_city(self, name="Rio de Janeiro"):
     state = State(name="Rio de Janeiro", code="RJ")
     return City(name=name, state=state)