Пример #1
0
    def test_push_to_realtime(self):
        # only do the test if realtime test server is configured
        if is_realtime_rest_configured():

            working_dir = shakemap_extract_dir()
            shake_event = ShakeEvent(working_dir=working_dir, event_id=SHAKE_ID, locale="en", data_is_local_flag=True)
            # generate report
            shake_event.render_map()
            # push to realtime django
            push_shake_event_to_rest(shake_event)
            # check shake event exists
            session = get_realtime_session()
            earthquake_url = generate_earthquake_detail_url(SHAKE_ID)
            response = session.get(earthquake_url)
            self.assertEqual(response.status_code, requests.codes.ok)

            event_dict = shake_event.event_dict()
            earthquake_data = {
                "shake_id": shake_event.event_id,
                "magnitude": float(event_dict.get("mmi")),
                "depth": float(event_dict.get("depth-value")),
                "time": shake_event.shake_grid.time.strftime(INASAFE_REALTIME_DATETIME_FORMAT),
                "location": {
                    "type": "Point",
                    "coordinates": [shake_event.shake_grid.longitude, shake_event.shake_grid.latitude],
                },
                "location_description": event_dict.get("place-name"),
            }

            for key, value in earthquake_data.iteritems():
                self.assertEqual(response.json()[key], value)
Пример #2
0
    def test_push_to_realtime(self):
        # only do the test if realtime test server is configured
        if is_realtime_rest_configured():

            working_dir = shakemap_extract_dir()
            shake_event = ShakeEvent(working_dir=working_dir,
                                     event_id=SHAKE_ID,
                                     locale='en',
                                     data_is_local_flag=True)
            # generate report
            shake_event.render_map()
            # push to realtime django
            push_shake_event_to_rest(shake_event)
            # check shake event exists
            session = get_realtime_session()
            earthquake_url = generate_earthquake_detail_url(SHAKE_ID)
            response = session.get(earthquake_url)
            self.assertEqual(response.status_code, requests.codes.ok)

            event_dict = shake_event.event_dict()
            earthquake_data = {
                'shake_id':
                shake_event.event_id,
                'magnitude':
                float(event_dict.get('mmi')),
                'depth':
                float(event_dict.get('depth-value')),
                'time':
                shake_event.shake_grid.time.strftime(
                    INASAFE_REALTIME_DATETIME_FORMAT),
                'location': {
                    'type':
                    'Point',
                    'coordinates': [
                        shake_event.shake_grid.longitude,
                        shake_event.shake_grid.latitude
                    ]
                },
                'location_description':
                event_dict.get('place-name')
            }

            for key, value in earthquake_data.iteritems():
                self.assertEqual(response.json()[key], value)
Пример #3
0
 def test_login_to_realtime(self):
     # get logged in session
     session = get_realtime_session()
     r = session.get(INASAFE_REALTIME_REST_URL + "?format=api")
     # find text called Log out
     self.assertIn("Log out", r.text)
Пример #4
0
 def test_login_to_realtime(self):
     # get logged in session
     session = get_realtime_session()
     r = session.get(INASAFE_REALTIME_REST_URL + '?format=api')
     # find text called Log out
     self.assertIn('Log out', r.text)