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')
 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]]
def http_mock_request(data_object):
    """
    Makes a mock request call and returns a dict formatted similar to a json file.
    Used for testing only.

    :param data_object: the data object that is being called (channelSoh, channel, channel-segment)
    :return: mocked data in a dictionary
    """

    if data_object == 'channel':
        mock_chan = read_json(os.path.dirname(__file__) + '/channel_mock.json')

        return mock_chan

    elif data_object == 'channel-segment':
        mock_chan_seg = read_json(
            os.path.dirname(__file__) + '/channel_segment_mock.json')

        return mock_chan_seg

    elif data_object == 'acquired-channel-soh':
        mock_chan_soh = read_json(
            os.path.dirname(__file__) + '/acquired_channel_soh_mock.json')

        return mock_chan_soh

    elif data_object == 'qc-mask':
        mock_qcmask = read_json(
            os.path.dirname(__file__) + '/qc_mask_mock.json')

        return mock_qcmask
    elif data_object == 'frame':
        mock_frame = read_json(os.path.dirname(__file__) + '/frame_mock.json')
        return mock_frame

    else:
        print('Error: http_mock_request(): data_object is not found')
    def test_frames_response(self, m):
        mock_json = str(
            read_json(os.path.dirname(__file__) + '/frame_mock.json'))

        starttime = '1970-01-02T03:04:05.123Z'
        endtime = '1970-01-02T03:04:07.123Z'

        params = set_params(starttime, endtime)

        input_url = url_waveforms + 'frames'
        print("input_url = " + input_url)

        m.get(input_url, text=mock_json)
        resp = http_request(None, 'frames', params).text
        self.assertEqual(resp, mock_json)
    def test_qc_mask_response(self, m):
        mock_json = str(
            read_json(os.path.dirname(__file__) + '/qc_mask_mock.json'))

        channelid = 100
        starttime = 200
        endtime = 300

        params = set_params(channelid, starttime, endtime)

        input_url = url_signal + 'qc-mask?channel-id=100&start-time=200&end-time=300'

        m.get(input_url, text=mock_json)
        resp = http_request(None, 'qc-mask', params).text
        self.assertEqual(resp, mock_json)
    def test_channel_soh_service_response(self, m):
        mock_json = str(
            read_json(
                os.path.dirname(__file__) + '/channel_segment_mock.json'))

        channelid = 100
        starttime = 200
        endtime = 300
        waveform = 'true'
        sohtype = 'boolean'

        params = set_params(channelid, starttime, endtime, waveform, sohtype)

        input_url = url_waveforms + "acquired-channel-soh/boolean?channel-id=100&start-time=200&end-time=300"

        m.get(input_url, text=mock_json)
        resp = http_request(None, 'acquired-channel-soh', params).text
        self.assertEqual(resp, mock_json)
Esempio n. 7
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.null = []