Exemplo n.º 1
0
 def test_parse_dict_null_qc_mask(self):
     output = io.StringIO()
     sys.stdout = output
     data_object = 'qc-mask'
     parse_dict(self.null, data_object)
     sys.stdout = sys.__stdout__
     self.assertEqual(output.getvalue(), "Error: Service Returned Null Qc-Mask Data\n")
Exemplo n.º 2
0
 def test_parse_dict_null_channel(self):
     output = io.StringIO()
     sys.stdout = output
     data_object = 'channel'
     parse_dict(self.null, data_object)
     sys.stdout = sys.__stdout__
     self.assertEqual(output.getvalue(), "Error: Service Returned Null Channel Data\n")
Exemplo n.º 3
0
 def test_parse_dict_null_soh(self):
     output = io.StringIO()
     sys.stdout = output
     data_object = 'acquired-channel-soh'
     parse_dict(self.null, data_object)
     sys.stdout = sys.__stdout__
     self.assertEqual(output.getvalue(), "Error: Service Returned Null Acquired-Channel-Soh Data\n")
Exemplo n.º 4
0
 def test_parse_dict_wrong_object(self):
     output = io.StringIO()
     sys.stdout = output
     data_object = 'wrong-object'
     parse_dict(self.null, data_object)
     sys.stdout = sys.__stdout__
     self.assertEqual(output.getvalue(), "Error: parse_dict(): data_object not found\n")
Exemplo n.º 5
0
 def setUp(self):
     self.soh_json = read_json(os.path.dirname(__file__) + '/acquired_channel_soh_mock.json')
     self.channel = read_json(os.path.dirname(__file__) + '/channel_mock.json')
     self.channel_segment = read_json(os.path.dirname(__file__) + '/channel_segment_mock.json')
     self.qc_mask_json = read_json(os.path.dirname(__file__) + '/qc_mask_mock.json')
     self.chan_seg = parse_dict(self.channel_segment, 'channel-segment')
     self.chan = parse_dict(self.channel, 'channel')
     self.soh = parse_dict(self.soh_json, 'acquired-channel-soh')
     self.qcmask = parse_dict(self.qc_mask_json, 'qc-mask')
Exemplo n.º 6
0
 def setUp(self):
     self.date = '1969-12-31T17:00:00Z'
     self.channel = read_json(
         os.path.dirname(__file__) + '/channel_mock.json')
     self.channel_segment = read_json(
         os.path.dirname(__file__) + '/channel_segment_mock.json')
     self.chan_seg = parse_dict(self.channel_segment, 'channel-segment')
     self.chan = parse_dict(self.channel, 'channel')
     self.dfile_base = 'waveform'
     self.dir = os.path.dirname(__file__)
     self.wfdisc = 'test.wfdisc'
     self.wfdisc_wav = 'test_one_wave.wfdisc'
     self.chan_seg_one_wv = parse_dict(self.channel_segment,
                                       'channel-segment')
     self.chan_seg_one_wv.waveform = [self.chan_seg_one_wv.waveform[0]]
Exemplo n.º 7
0
    def test_parse_dict_soh(self):
        data_object = 'acquired-channel-soh'
        soh = parse_dict(self.soh_json, data_object)

        self.assertEqual(soh[0].processing_channel_id, self.soh_json[0]['processingChannelId'])
        self.assertEqual(soh[0].acquired_channel_soh_type, self.soh_json[0]['type'])
        self.assertEqual(soh[0].start_time, self.soh_json[0]['startTime'])
        self.assertEqual(soh[0].end_time, self.soh_json[0]['endTime'])
        self.assertEqual(soh[0].status_type, self.soh_json[0]['status'])
Exemplo n.º 8
0
    def test_parse_dict_channel_segment(self):
        data_object = 'channel-segment'
        chan_seg = parse_dict(self.channel_segment, data_object)

        self.assertEqual(chan_seg.name, self.channel_segment['name'])
        self.assertEqual(chan_seg.processing_channel_id, self.channel_segment['processingChannelId'])
        self.assertEqual(chan_seg.id, self.channel_segment['id'])
        self.assertEqual(chan_seg.channel_segment_type, self.channel_segment['segmentType'])
        self.assertEqual(chan_seg.start_time, self.channel_segment['startTime'])
        self.assertEqual(chan_seg.end_time, self.channel_segment['endTime'])
        self.assertEqual(chan_seg.waveform[0].end_time, self.channel_segment['waveforms'][0]['endTime'])
        self.assertEqual(chan_seg.waveform[0].start_time, self.channel_segment['waveforms'][0]['startTime'])
        self.assertEqual(chan_seg.waveform[0].sample_count, self.channel_segment['waveforms'][0]['sampleCount'])
        self.assertEqual(chan_seg.waveform[0].sample_rate, self.channel_segment['waveforms'][0]['sampleRate'])
        self.assertEqual(chan_seg.waveform[0].values, self.channel_segment['waveforms'][0]['values'])
Exemplo n.º 9
0
    def test_parse_dict_channel(self):
        data_object = 'channel'
        chan = parse_dict(self.channel, data_object)

        self.assertEqual(chan.name, self.channel['name'])
        self.assertEqual(chan.channel_type, self.channel['type'])
        self.assertEqual(chan.sites.name, self.channel['sites']['name'])
        self.assertEqual(chan.sites.channels, self.channel['sites']['channels'])
        self.assertEqual(chan.sites.station.name, self.channel['sites']['station']['name'])
        self.assertEqual(chan.sites.station.elevation, self.channel['sites']['station']['elevation'])
        self.assertEqual(chan.sites.station.longitude, self.channel['sites']['station']['longitude'])
        self.assertEqual(chan.sites.station.latitude, self.channel['sites']['station']['latitude'])
        self.assertEqual(chan.sites.station.station_type, self.channel['sites']['station']['stationType'])
        self.assertEqual(chan.instruments.instrument_model, self.channel['instruments']['instrumentModel'])
        self.assertEqual(chan.calibration.calibration_period, self.channel['calibration']['period'])
        self.assertEqual(chan.calibration.calibration_factor, self.channel['calibration']['factor'])
Exemplo n.º 10
0
    if channelid is None:
        print('Parameter channel_id is required for metadata')
        raise TypeError
    starttime = format_time(starttime, startdate)
    endtime = format_time(endtime, enddate)
    params = set_params(channel_id=channelid,
                        start_time=starttime,
                        end_time=endtime,
                        with_waveforms=False)
    channel_segment = http_request(None, 'channel-segment', params, 'json')
    # channel = http_request('channel', params, 'json')
    # mocked
    channel = http_mock_request('channel')
    # channel_segment = http_mock_request('channel-segment')

    chan_seg = parse_dict(channel_segment, 'channel-segment')
    chan = parse_dict(channel, 'channel')

    if table is True:
        table_waveform(chan_seg, chan)

elif data_type == 'waveforms':
    if channelid is None:
        print('Parameter channel_id is required for waveforms')
        raise TypeError
    starttime = format_time(starttime, startdate)
    endtime = format_time(endtime, enddate)
    params = set_params(channel_id=channelid,
                        start_time=starttime,
                        end_time=endtime,
                        with_waveforms=True)
Exemplo n.º 11
0
    def test_parse_dict_qc_mask(self):
        data_object = 'qc-mask'
        qc = parse_dict(self.qc_mask_json, data_object)

        self.assertEqual(qc[0].id, self.qc_mask_json[0]['id'])
        self.assertEqual(qc[0].processing_channel_id, self.qc_mask_json[0]['processingChannelId'])