コード例 #1
0
def test_get_file_for_url__throws_exception():
    """Util_test.test_get_file_for_url__throws_exception()"""
    # throws exception for non "file://" urls
    try:
        Util.get_file_from_url("http://someserver/path")
        assert False, "expected exception"
    except Exception:
        pass
コード例 #2
0
def test_get_file_for_url__throws_exception():
    """Util_test.test_get_file_for_url__throws_exception()
    """
    # throws exception for non "file://" urls
    try:
        Util.get_file_from_url('http://someserver/path')
        assert_false('expected exception')
    except Exception:
        pass
コード例 #3
0
def test_get_interval__trim():
    """Util_test.test_get_interval__trim()
    """
    starttime = UTCDateTime('2015-01-01T01:00:00Z')
    endtime = UTCDateTime('2015-01-02T00:00:00Z')
    intervals = Util.get_intervals(starttime, endtime, trim=True)
    assert_equals(intervals[0]['start'], starttime)
コード例 #4
0
def test_get_interval__custom_size():
    """Util_test.test_get_interval__custom_size()
    """
    starttime = UTCDateTime('2015-01-01T00:00:00Z')
    endtime = UTCDateTime('2015-01-02T00:00:00Z')
    intervals = Util.get_intervals(starttime, endtime, size=3600)
    assert_equals(len(intervals), 24)
コード例 #5
0
def test_get_interval__defaults():
    """Util_test.test_get_interval()
    """
    starttime = UTCDateTime('2015-01-01T00:00:00Z')
    endtime = UTCDateTime('2015-02-01T00:00:00Z')
    intervals = Util.get_intervals(starttime, endtime)
    assert_equals(len(intervals), 31)
コード例 #6
0
def test_get_interval__trim():
    """Util_test.test_get_interval__trim()
    """
    starttime = UTCDateTime('2015-01-01T01:00:00Z')
    endtime = UTCDateTime('2015-01-02T00:00:00Z')
    intervals = Util.get_intervals(starttime, endtime, trim=True)
    assert_equals(intervals[0]['start'], starttime)
コード例 #7
0
def test_get_interval__custom_size():
    """Util_test.test_get_interval__custom_size()
    """
    starttime = UTCDateTime('2015-01-01T00:00:00Z')
    endtime = UTCDateTime('2015-01-02T00:00:00Z')
    intervals = Util.get_intervals(starttime, endtime, size=3600)
    assert_equals(len(intervals), 24)
コード例 #8
0
def test_get_interval__defaults():
    """Util_test.test_get_interval()
    """
    starttime = UTCDateTime('2015-01-01T00:00:00Z')
    endtime = UTCDateTime('2015-02-01T00:00:00Z')
    intervals = Util.get_intervals(starttime, endtime)
    assert_equals(len(intervals), 31)
コード例 #9
0
def test_get_interval__negative_size():
    """Util_test.test_get_interval__negative_size()"""
    starttime = UTCDateTime("2015-01-01T00:00:00Z")
    endtime = UTCDateTime("2015-01-02T00:00:00Z")
    intervals = Util.get_intervals(starttime, endtime, size=-1)
    assert_equal(len(intervals), 1)
    assert_equal(intervals[0]["start"], starttime)
    assert_equal(intervals[0]["end"], endtime)
コード例 #10
0
def test_get_interval__negative_size():
    """Util_test.test_get_interval__negative_size()
    """
    starttime = UTCDateTime('2015-01-01T00:00:00Z')
    endtime = UTCDateTime('2015-01-02T00:00:00Z')
    intervals = Util.get_intervals(starttime, endtime, size=-1)
    assert_equals(len(intervals), 1)
    assert_equals(intervals[0]['start'], starttime)
    assert_equals(intervals[0]['end'], endtime)
コード例 #11
0
def test_get_file_for_url__creates_directories():
    """Util_test.test_get_file_for_url__creates_directories()
    """
    # creates directories if requested
    if os.path.isdir('/tmp/_geomag_algorithms_test_'):
        shutil.rmtree('/tmp/_geomag_algorithms_test_')
    f = Util.get_file_from_url('file:///tmp/_geomag_algorithms_test_/somefile',
                               createParentDirectory=True)
    if not os.path.isdir('/tmp/_geomag_algorithms_test_'):
        assert_false('directory not created')
    shutil.rmtree('/tmp/_geomag_algorithms_test_')
    assert_equals(f, '/tmp/_geomag_algorithms_test_/somefile')
コード例 #12
0
def test_get_file_for_url__creates_directories():
    """Util_test.test_get_file_for_url__creates_directories()"""
    # creates directories if requested
    if os.path.isdir("/tmp/_geomag_algorithms_test_"):
        shutil.rmtree("/tmp/_geomag_algorithms_test_")
    f = Util.get_file_from_url(
        "file:///tmp/_geomag_algorithms_test_/somefile", createParentDirectory=True
    )
    if not os.path.isdir("/tmp/_geomag_algorithms_test_"):
        assert False, "directory not created"
    shutil.rmtree("/tmp/_geomag_algorithms_test_")
    assert_equal(f, "/tmp/_geomag_algorithms_test_/somefile")
コード例 #13
0
def test_get_file_for_url__creates_directories():
    """Util_test.test_get_file_for_url__creates_directories()
    """
    # creates directories if requested
    if os.path.isdir('/tmp/_geomag_algorithms_test_'):
        shutil.rmtree('/tmp/_geomag_algorithms_test_')
    f = Util.get_file_from_url('file:///tmp/_geomag_algorithms_test_/somefile',
            createParentDirectory=True)
    if not os.path.isdir('/tmp/_geomag_algorithms_test_'):
        assert_false('directory not created')
    shutil.rmtree('/tmp/_geomag_algorithms_test_')
    assert_equals(f, '/tmp/_geomag_algorithms_test_/somefile')
コード例 #14
0
def test_get_file_for_url__parses_file_urls():
    """Util_test.test_get_file_for_url__parses_file_urls()
    """
    # parses file urls
    f = Util.get_file_from_url('file://./somefile')
    assert_equals(f, './somefile')
コード例 #15
0
def test_get_file_for_url__parses_file_urls():
    """Util_test.test_get_file_for_url__parses_file_urls()
    """
    # parses file urls
    f = Util.get_file_from_url('file://./somefile')
    assert_equals(f, './somefile')