Beispiel #1
0
    def test_events2dicts(self) -> None:
        """Basic usage."""

        json.dump([
            {
                'title': 'Event A',
                'organiser': 'Pascal',
                'latitude': 45.75,
                'longitude': 4.85,
                'price': 0,
                'id': 'event-a',
                'slug': 'slug-event-a',
                'date': '2017-08-19',
                'category': ['Trouver un job'],
            },
        ], self.events_file)
        self.events_file.close()

        collection = workup_events.events2dicts(
            self.events_json_path,
            io.StringIO('''departement_id,max_latitude,max_longitude,min_latitude,min_longitude
38,45.8667,6.18333,44.75,4.76667
69,46.2833,5.1116,45.45,4.3
75,48.86,2.34445,48.86,2.34445
'''))
        event_protos = dict(mongo.collection_to_proto_mapping(
            collection, event_pb2.Event))
        self.assertEqual({'event-a'}, set(event_protos))
        event = event_protos['event-a']
        self.assertEqual('Event A', event.title)
        self.assertEqual('https://www.workuper.com/events/slug-event-a', event.link)
        self.assertEqual(['for-departement(38,69)'], event.filters)
Beispiel #2
0
    def test_create_company_event(self) -> None:
        """Event to learn how to create a company."""

        json.dump([
            {
                'title': 'Event A',
                'organiser': 'Pascal',
                'latitude': 45.75,
                'longitude': 4.85,
                'price': 0,
                'id': 'event-a',
                'slug': 'slug-event-a',
                'date': '2017-08-19',
                'category': ['Créer sa boite'],
            },
        ], self.events_file)
        self.events_file.close()

        collection = workup_events.events2dicts(
            self.events_json_path,
            io.StringIO('''departement_id,max_latitude,max_longitude,min_latitude,min_longitude
38,45.8667,6.18333,44.75,4.76667
69,46.2833,5.1116,45.45,4.3
75,48.86,2.34445,48.86,2.34445
'''))

        self.assertFalse(collection)
Beispiel #3
0
    def test_cosly_event(self):
        """Non-free event."""

        json.dump([
            {
                'title': 'Event A',
                'organiser': 'Pascal',
                'latitude': 45.75,
                'longitude': 4.85,
                'price': 1,
                'id': 'event-a',
                'slug': 'slug-event-a',
                'date': '2017-08-19',
                'category': ['Trouver un job'],
            },
        ], self.events_file)
        self.events_file.close()

        collection = workup_events.events2dicts(
            self.events_json_path,
            io.StringIO(
                '''departement_id,max_latitude,max_longitude,min_latitude,min_longitude
38,45.8667,6.18333,44.75,4.76667
69,46.2833,5.1116,45.45,4.3
75,48.86,2.34445,48.86,2.34445
'''))

        self.assertFalse(collection)