コード例 #1
0
    def test_importUpdated(self, session=None):
        json_file = os.path.join(get_test_dir(), 'data', 'geojson',
                                 'first.json')

        pg = ProductGrabber()
        with open(json_file, 'r') as json_file_:
            pg.json_feed = json.loads(json_file_.read())

        pg.read_json_feed()
        pg.get_new_events()

        event = session.query(Event).filter(
            Event.event_id == 'us6000bdgz').first()
        self.assertIsNotNone(event)

        pg = ProductGrabber()
        json_file = os.path.join(get_test_dir(), 'data', 'geojson',
                                 'updated.json')
        with open(json_file, 'r') as json_file_:
            pg.json_feed = json.loads(json_file_.read())

        pg.read_json_feed()
        pg.get_new_events()

        event = session.query(Event).filter(Event.event_id == 'NEW_ID').first()

        self.assertIsNotNone(event)
コード例 #2
0
    def test_scenarioRun(self, session=None):
        # import from directory
        scenario_directory = os.path.join(get_test_dir(), 'data', 'new_event', 'new_event-1')
        event, shakemap = grab_from_directory(scenario_directory, session=session)

        result = run_scenario(shakemap.shakemap_id)
        self.assertTrue(result['message']['success'])
コード例 #3
0
    def test_imports(self, session=None):
        scenario_directory = os.path.join(get_test_dir(), 'data', 'new_event',
                                          'new_event-1')
        event, shakemap = grab_from_directory(scenario_directory,
                                              session=session)

        shakemap_from_db = session.query(ShakeMap).filter(
            ShakeMap.shakemap_id == event.event_id).first()
        self.assertIsNotNone(shakemap_from_db)
コード例 #4
0
ファイル: sc_csv.py プロジェクト: NNovoa-CDWR/shakecast
    def test_imports(self, session=None):
        scenario_directory = os.path.join(get_test_dir(), 'data', 'new_event',
                                          'new_event-1')
        event, shakemap = grab_from_directory(scenario_directory,
                                              session=session)

        group = Group(name='TESTGROUP')

        csv_name = 'test_csv'
        csv_result = main(group, shakemap, name=csv_name)

        path = os.path.join(shakemap.local_products_dir, csv_name)
        self.assertTrue(os.path.exists(path))
コード例 #5
0
def preload_data(session=None):
    # import from directory
    scenario_directory = os.path.join(get_test_dir(), 'data', 'new_event',
                                      'new_event-1')
    event, shakemap = grab_from_directory(scenario_directory, session=session)

    grid = create_grid(shakemap)
    facility = create_fac(grid)
    group = create_group('GLOBAL')
    group2 = create_group('GLOBAL_SCENARIO', event_type='SCENARIO')
    user = create_user()
    group.facilities += [facility]
    group2.facilities += [facility]
    group.users += [user]
    group2.users += [user]

    session.add(group)
    session.add(group2)
    session.commit()