예제 #1
0
파일: test_model.py 프로젝트: qira03/vcb
 def test_longitude_float(self):
     """Comprueba que la longitud sea un número flotante."""
     venue = Venue(name="Lugar 1",
                   address="Calle abc",
                   latitude=1.123,
                   longitude="Cadena")
     with self.assertRaisesRegex(ValidationError, "(longitude)"):
         venue.full_clean()
예제 #2
0
파일: test_model.py 프로젝트: qira03/vcb
 def test_website_url(self):
     """Comprueba que el website sea una URL."""
     venue = Venue(name="Lugar 1",
                   address="Calle abc",
                   website="No es una URL",
                   latitude=1.123,
                   longitude=1.123)
     with self.assertRaisesRegex(ValidationError, "(website).*(URL)"):
         venue.full_clean()
예제 #3
0
파일: test_model.py 프로젝트: qira03/vcb
 def test_state_length(self):
     """Prueba la longitud del departamento."""
     venue = Venue(name="Lugar 1",
                   address="Calle abc",
                   state="Lorem ipsum dolor sit amet, consect",
                   latitude=1.123,
                   longitude=1.123)
     with self.assertRaisesRegex(ValidationError, "(state).*(32)"):
         venue.full_clean()
예제 #4
0
파일: test_model.py 프로젝트: qira03/vcb
 def test_phone_length(self):
     """Comprueba la longitud del teléfono."""
     venue = Venue(name="Lugar 1",
                   address="Calle abc",
                   phone="Lorem ipsum dolor si",
                   latitude=1.123,
                   longitude=1.123)
     with self.assertRaisesRegex(ValidationError, "(phone).*(18)"):
         venue.full_clean()
예제 #5
0
파일: test_model.py 프로젝트: qira03/vcb
 def test_city_length(self):
     """Prueba la longitud de la ciudad."""
     venue = Venue(name="Lugar 1",
                   address="Calle abc",
                   city="Lorem ipsum dolor sit amet, consect",
                   latitude=1.123,
                   longitude=1.123)
     with self.assertRaisesRegex(ValidationError, "(city).*(32)"):
         venue.full_clean()
예제 #6
0
파일: test_model.py 프로젝트: qira03/vcb
 def test_address_length(self):
     """Prueba la longitud de la dirección."""
     venue = Venue(
         name="Lugar 1",
         address="Lorem ipsum dolor sit amet, consectetuer adipiscing "\
             "elit Aenean commo",
         latitude=1.123,
         longitude=1.123
     )
     with self.assertRaisesRegex(ValidationError, "(address).*(64)"):
         venue.full_clean()
예제 #7
0
파일: test_model.py 프로젝트: qira03/vcb
 def test_name_length(self):
     """Prueba de longitud del nombre."""
     venue = Venue(
         name="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. "\
             "Aenean commodo ligula eget dolor aenean",
         address="Calle abc",
         latitude=1.123,
         longitude=1.123
     )
     with self.assertRaisesRegex(ValidationError, "(name).*(96)"):
         venue.full_clean()
예제 #8
0
    def test_event_visibility(self):
        response = testing.get_public_client().get(reverse('event_index'))
        self.assertEqual(200, response.status_code)

        author = testing.create_user()
        venue = Venue.create_for_testing()

        event_a = Event.create_for_testing(author, venue)
        event_a.reviewed = True
        event_a.save()

        event_b = Event.create_for_testing(author, venue)
        event_b.reviewed = False
        event_b.save()

        # The general public should see only the reviewed event.
        response = testing.get_public_client().get(reverse('event_index'))
        self.assertEqual(200, response.status_code)
        self.assertEqual(1, len(response.context['events']))

        # The author should see both.
        response = testing.get_user_client(author).get(reverse('event_index'))
        self.assertEqual(200, response.status_code)
        self.assertEqual(2, len(response.context['events']))

        # Another regular user should also see both.
        response = testing.get_user_client().get(reverse('event_index'))
        self.assertEqual(200, response.status_code)
        self.assertEqual(2, len(response.context['events']))
예제 #9
0
    def clean(self):
        cleaned_data = super().clean()

        venue = None
        if 'venue_selection' in cleaned_data:
            venue = cleaned_data['venue_selection']

        if not venue:
            name = cleaned_data['venue_name']
            town = cleaned_data['venue_town']
            street = cleaned_data['venue_street']
            if name and town and street:
                venue = Venue()
                venue.name = name
                venue.town = town
                venue.street = street
                venue.clean()
            else:
                self.add_error('venue_selection', 'Wybierz miejsce z listy '
                               'lub wypełnij formularz aby dodać nowe miejsce.')

        cleaned_data['venue'] = venue
        return cleaned_data
예제 #10
0
파일: forms.py 프로젝트: jakubkwa/piosenka
    def clean(self):
        cleaned_data = super().clean()

        venue = None
        if "venue_selection" in cleaned_data:
            venue = cleaned_data["venue_selection"]

        if not venue:
            name = cleaned_data["venue_name"]
            town = cleaned_data["venue_town"]
            street = cleaned_data["venue_street"]
            if name and town and street:
                venue = Venue()
                venue.name = name
                venue.town = town
                venue.street = street
                venue.clean()
            else:
                self.add_error(
                    "venue_selection", "Wybierz miejsce z listy " "lub wypełnij formularz aby dodać nowe miejsce."
                )

        cleaned_data["venue"] = venue
        return cleaned_data
예제 #11
0
def test_venue_has_necessary_fields():
    venue = Venue()

    assert True == hasattr(venue, 'id')
    assert True == hasattr(venue, 'name')
예제 #12
0
def test_venue_has_meaningful_string_representation():
    test_venue_name = 'Sydney Opera House'

    venue = Venue(name=test_venue_name)

    assert test_venue_name == str(venue)