Exemplo n.º 1
0
def test_datetime_from_string():
    ('DateTime#from_string() should have cast the value as string')

    # Given an instance of datetime
    instance = DateTime()

    # When I call from_string
    result = instance.from_string('2015-08-25 15:57:37-04:00')

    # Then the result should be a UUID
    result.should.be.an(datetime)
Exemplo n.º 2
0
def test_datetime_get_base_type():
    ('DateTime#get_base_type() should return the __base_type__')

    # Given an instance of datetime
    instance = DateTime()

    # When I call get_base_type
    result = instance.get_base_type()

    # Then the result should be bytes
    result.should.equal(datetime)
Exemplo n.º 3
0
def test_datetime_get_base_type():
    ('DateTime#get_base_type() should return the __base_type__')

    # Given an instance of datetime
    instance = DateTime()

    # When I call get_base_type
    result = instance.get_base_type()

    # Then the result should be bytes
    result.should.equal(datetime)
Exemplo n.º 4
0
def test_datetime_to_string():
    ('DateTime#to_string() should have cast the value as string')

    # Given an instance of datetime
    instance = DateTime()

    # When I call to_string
    result = instance.to_string('2015-08-25 15:57:37-04:00')

    # Then the result should be a string
    result.should.be.a(bytes)
Exemplo n.º 5
0
def test_datetime_from_string():
    ('DateTime#from_string() should have cast the value as string')

    # Given an instance of datetime
    instance = DateTime()

    # When I call from_string
    result = instance.from_string('2015-08-25 15:57:37-04:00')

    # Then the result should be a UUID
    result.should.be.an(datetime)
Exemplo n.º 6
0
def test_datetime_to_string():
    ('DateTime#to_string() should have cast the value as string')

    # Given an instance of datetime
    instance = DateTime()

    # When I call to_string
    result = instance.to_string('2015-08-25 15:57:37-04:00')

    # Then the result should be a string
    result.should.be.a(bytes)
Exemplo n.º 7
0
def test_datetime_to_json():
    ('DateTime.to_json() should deserialize the given dict into a value')

    # Given an instance of datetime
    instance = DateTime()

    # When I call to_json
    result = instance.to_json(u'Tue Aug 25 15:57:37 EDT 2015')

    # Then the result should be a value
    result.should.equal(
        '{"type": "DateTime", "value": "2015-08-25T15:57:37-04:00", "module": "repocket.attributes"}'
    )
Exemplo n.º 8
0
def test_datetime_to_json():
    ('DateTime.to_json() should deserialize the given dict into a value')

    # Given an instance of datetime
    instance = DateTime()

    # When I call to_json
    result = instance.to_json(u'Tue Aug 25 15:57:37 EDT 2015')

    # Then the result should be a value
    result.should.equal(
        '{"type": "DateTime", "value": "2015-08-25T15:57:37-04:00", "module": "repocket.attributes"}'
    )
Exemplo n.º 9
0
def test_datetime_to_python():
    ('DateTime#to_python() should prepare data to be serialized')

    # Given an instance of datetime
    instance = DateTime()

    # When I call to_python
    result = instance.to_python('Tue Aug 25 15:57:37 EDT 2015')

    # Then the result should be a dictionary with metadata
    result.should.equal({
        'module': 'repocket.attributes',
        'type': 'DateTime',
        'value': '2015-08-25T15:57:37-04:00',
    })
Exemplo n.º 10
0
def test_datetime_to_python():
    ('DateTime#to_python() should prepare data to be serialized')

    # Given an instance of datetime
    instance = DateTime()

    # When I call to_python
    result = instance.to_python('Tue Aug 25 15:57:37 EDT 2015')

    # Then the result should be a dictionary with metadata
    result.should.equal({
        'module': 'repocket.attributes',
        'type': 'DateTime',
        'value': '2015-08-25T15:57:37-04:00',
    })
Exemplo n.º 11
0
def test_datetime_from_json():
    ('DateTime.from_json() should deserialize the given dict into a value')

    # Given an instance of datetime
    instance = DateTime()

    # When I call from_json
    result = instance.from_json(json.dumps({
        b'module': b'repocket.attributes',
        b'type': b'DateTime',
        b'value': b'Tue Aug 25 15:57:37 EDT 2015',
    }))

    # Then the result should be a value
    result.should.be.a(datetime)
    result.replace(tzinfo=None).should.equal(datetime(2015, 8, 25, 15, 57, 37))
Exemplo n.º 12
0
def test_datetime_from_python():
    ('DateTime.from_python() should deserialize the given dict into a value')

    # Given an instance of datetime
    instance = DateTime()

    # When I call from_python
    result = instance.from_python({
        b'module': b'repocket.attributes',
        b'type': b'DateTime',
        b'value': u'Tue Aug 25 15:57:37 EDT 2015',
    })

    # Then the result should be a value
    result.should.be.a(datetime)
    result.replace(tzinfo=None).should.equal(datetime(2015, 8, 25, 15, 57, 37))