Exemplo n.º 1
0
def test_get_timestamp_suffix():
    # we need to patch temporarily TZ
    with patch.dict('os.environ', {'TZ': 'GMT'}):
        # skynet DOB
        target_ts = '1970-01-01T00:00:00-0000' \
            if on_windows else '1970-01-01T00:00:00+0000'
        assert_equal(get_timestamp_suffix(0), '-' + target_ts)
        assert_equal(get_timestamp_suffix(0, prefix="+"), '+' + target_ts)
        # yoh found no way to mock things out and didn't want to provide
        # explicit call to anything to get current time with the timezone,
        # so disabling this test for now besides that it should return smth
        # sensible ;)
        #with patch.object(time, 'localtime', lambda: 1):
        #    assert_equal(get_timestamp_suffix(),
        #  '-1970-01-01T00:00:01+0000')  # skynet is 1 sec old
        assert (get_timestamp_suffix().startswith('-'))
Exemplo n.º 2
0
def test_get_timestamp_suffix():
    # we need to patch temporarily TZ
    with patch.dict('os.environ', {'TZ': 'GMT'}):
        # figure out how GMT time zone suffix is represented
        # could be +0 or -0, depending on platform
        # just use whatever it is, not the subject of this test
        tz_suffix = time.strftime('%z', time.gmtime(0))
        # skynet DOB
        target_ts = '1970-01-01T00:00:00' + tz_suffix
        assert_equal(get_timestamp_suffix(0), '-' + target_ts)
        assert_equal(get_timestamp_suffix(0, prefix="+"), '+' + target_ts)
        # yoh found no way to mock things out and didn't want to provide
        # explicit call to anything to get current time with the timezone,
        # so disabling this test for now besides that it should return smth
        # sensible ;)
        #with patch.object(time, 'localtime', lambda: 1):
        #    assert_equal(get_timestamp_suffix(),
        #  '-1970-01-01T00:00:01+0000')  # skynet is 1 sec old
        assert (get_timestamp_suffix().startswith('-'))