コード例 #1
0
def test_mixed_case_file_names():
    mixed_case_f_names_order_1 = os.path.join(gem_mocks.TEST_DATA_DIR,
                                              'mixed_case_1.txt')
    mixed_case_f_names_order_2 = os.path.join(gem_mocks.TEST_DATA_DIR,
                                              'mixed_case_2.txt')
    test_obs_id = 'GN-CAL20100415-6-086-BIAS'
    test_file_id = 'N20100415S0452_bias'

    for f_name in [mixed_case_f_names_order_1, mixed_case_f_names_order_2]:
        import shutil
        shutil.copy(f_name, '/app/data/from_paul.txt')
        test_subject = GemObsFileRelationship()

        result_obs_id = test_subject.get_obs_id(test_file_id)
        assert result_obs_id is not None, 'expected result {}'.format(f_name)
        assert result_obs_id == test_obs_id, 'wrong result {}'.format(f_name)

        test_timestamp = test_subject.get_timestamp(test_file_id)
        assert test_timestamp is not None, 'expected result {}'.format(f_name)
        assert test_timestamp == 1498316473.885391, 'wrong timestamp'

        result_file_names = test_subject.get_file_names(test_obs_id)
        assert result_file_names is not None, 'expected result {}'.format(
            f_name)
        assert len(result_file_names) == 1, 'wrong size result {}'.format(
            f_name)
        assert result_file_names[0] == '{}.fits'.format(test_file_id), \
            'wrong result {} {}'.format(f_name, result_file_names)
コード例 #2
0
def test_subset_all():
    gofr = GemObsFileRelationship(TEST_FILE)
    temp = gofr.subset()
    assert temp is not None, 'should have content'
    assert temp[0].startswith(
        'GEMINI GN-CAL20170616-11-022 2017-06-19T03:21:29.345'), \
        'wrong content'
    assert len(list(temp)) == 513, 'wrong count'
    result = gofr.get_file_names('GN-2015B-Q-1-12-1003')
    assert result == \
           ['N20150807G0044m.fits', 'N20150807G0044i.fits',
            'N20150807G0044.fits'], \
        'entry missing {}'.format(result)