Example #1
0
def test_pickle():
    """
    Make sure a Pickled entity comes out with the same values
    """
    entity = SampleEntity(id=1,
                          name='test name',
                          slug='test-slug',
                          url='http://example.com',
                          book=True,
                          collection=['a', 'b', 'c', 'd'],
                          entity_collection=[
                              SampleEntity(id=2),
                              SampleEntity(id=3),
                              SampleEntity(id=4)
                          ],
                          entity=SampleEntity(id=5, name='sample 5'),
                          date=utcnow())

    pickled = pickle.dumps(entity)
    entity2 = pickle.loads(pickled)

    assert entity == entity2

    # Change attributes to make sure every un-pickled ok
    entity2.name = 'New name'
    assert entity2.name == 'New name'
def test_pickle():
    """
    Make sure a Pickled entity comes out with the same values
    """
    entity = SampleEntity(
        id=1,
        name='test name',
        slug='test-slug',
        url='http://example.com',
        book=True,
        collection=['a', 'b', 'c', 'd'],
        entity_collection=[SampleEntity(id=2),SampleEntity(id=3),SampleEntity(id=4)],
        entity=SampleEntity(id=5, name='sample 5'),
        date=utcnow()
    )


    pickled = pickle.dumps(entity)
    entity2 = pickle.loads(pickled)

    assert entity == entity2

    # Change attributes to make sure every un-pickled ok
    entity2.name = 'New name'
    assert entity2.name == 'New name'
Example #3
0
def test_rfc3339():
    """
    Assure that RFC3339 formatting is working.

    Warning: This test could get different results depending on if pytz and dateutil is installed.
    """

    n = utcnow()
    offset = n.tzinfo.utcoffset(n)
    assert offset == timedelta(0)

    str = generate_rfc3339(n)
    
    assert 'T' in str
    assert str.endswith('Z')

    dt = date_parse(str)

    # `generate_rfc3339` does not convert microseconds so we can't compare them
    odt = n.replace(microsecond=0)

    assert dt == odt
Example #4
0
def test_rfc3339():
    """
    Assure that RFC3339 formatting is working.

    Warning: This test could get different results depending on if pytz and dateutil is installed.
    """

    n = utcnow()
    offset = n.tzinfo.utcoffset(n)
    assert offset == timedelta(0)

    str = generate_rfc3339(n)

    assert 'T' in str
    assert str.endswith('Z')

    dt = date_parse(str)

    # `generate_rfc3339` does not convert microseconds so we can't compare them
    odt = n.replace(microsecond=0)

    assert dt == odt