Skip to content

Commit

Permalink
Revert "Merge pull request #3 from dannyroberts/precise-datetime"
Browse files Browse the repository at this point in the history
This reverts commit 8f30aec, reversing
changes made to 7e8450b.
  • Loading branch information
dannyroberts committed Feb 3, 2014
1 parent 19ea58d commit 306a5b4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

install_requires = [
'restkit>=4.2.2',
'jsonobject>=0.3.0',
'jsonobject>=0.2.0',
],
provides=['couchdbkit'],
obsoletes=['couchdbkit'],
Expand Down
70 changes: 35 additions & 35 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ class B(Document):
'sm': {'doc_type': 'A', 's': u'foo'}})

b.created = datetime(2009, 2, 6, 18, 58, 20, 905556)
self.assert_(b._doc == {'created': '2009-02-06T18:58:20.905556Z',
self.assert_(b._doc == {'created': '2009-02-06T18:58:20Z',
'doc_type': 'B',
's1': None,
's2': None,
Expand All @@ -970,14 +970,14 @@ class B(Document):
self.assert_(isinstance(b.created, datetime) == True)

a.created = datetime(2009, 2, 6, 20, 58, 20, 905556)
self.assert_(a._doc == {'created': '2009-02-06T20:58:20.905556Z',
self.assert_(a._doc == {'created': '2009-02-06T20:58:20Z',
'doc_type': 'A', 's': u'foo'})

self.assert_(b._doc == {'created': '2009-02-06T18:58:20.905556Z',
self.assert_(b._doc == {'created': '2009-02-06T18:58:20Z',
'doc_type': 'B',
's1': None,
's2': None,
'sm': {'created': '2009-02-06T20:58:20.905556Z', 'doc_type': 'A',
'sm': {'created': '2009-02-06T20:58:20Z', 'doc_type': 'A',
's': u'foo'}})


Expand Down Expand Up @@ -1375,14 +1375,14 @@ class A(Document):
d = datetime(2009, 4, 13, 22, 56, 10, 967388)
a.l.append(d)
self.assert_(len(a.l) == 1)
self.assert_(a.l[0] == datetime(2009, 4, 13, 22, 56, 10, 967388))
self.assert_(a._doc == {'doc_type': 'A', 'l': ['2009-04-13T22:56:10.967388Z']})
self.assert_(a.l[0] == datetime(2009, 4, 13, 22, 56, 10))
self.assert_(a._doc == {'doc_type': 'A', 'l': ['2009-04-13T22:56:10Z']})
a.save()

b = A.get(a._id)
self.assert_(len(b.l) == 1)
self.assert_(b.l[0] == datetime(2009, 4, 13, 22, 56, 10, 967388))
self.assert_(b._doc['l'] == ['2009-04-13T22:56:10.967388Z'])
self.assert_(b.l[0] == datetime(2009, 4, 13, 22, 56, 10))
self.assert_(b._doc['l'] == ['2009-04-13T22:56:10Z'])

def testListPropertyNotEmpty(self):
from datetime import datetime
Expand All @@ -1401,8 +1401,8 @@ class A(Document):
d = datetime(2009, 4, 13, 22, 56, 10, 967388)
a.l.append(d)
self.assert_(len(a.l) == 1)
self.assert_(a.l[0] == datetime(2009, 4, 13, 22, 56, 10, 967388))
self.assert_(a._doc == {'doc_type': 'A', 'l': ['2009-04-13T22:56:10.967388Z']})
self.assert_(a.l[0] == datetime(2009, 4, 13, 22, 56, 10))
self.assert_(a._doc == {'doc_type': 'A', 'l': ['2009-04-13T22:56:10Z']})
a.validate()

class A2(Document):
Expand Down Expand Up @@ -1559,18 +1559,18 @@ class A(Document):

a = A()
a.d['test'] = { 'a': datetime(2009, 5, 10, 21, 19, 21, 127380) }
self.assert_(a.d == { 'test': {'a': datetime(2009, 5, 10, 21, 19, 21, 127380)}})
self.assert_(a._doc == {'d': {'test': {'a': '2009-05-10T21:19:21.127380Z'}}, 'doc_type': 'A'} )
self.assert_(a.d == { 'test': {'a': datetime(2009, 5, 10, 21, 19, 21)}})
self.assert_(a._doc == {'d': {'test': {'a': '2009-05-10T21:19:21Z'}}, 'doc_type': 'A'} )

a.d['test']['b'] = "essai"
self.assert_(a._doc == {'d': {'test': {'a': '2009-05-10T21:19:21.127380Z', 'b': 'essai'}}, 'doc_type': 'A'})
self.assert_(a._doc == {'d': {'test': {'a': '2009-05-10T21:19:21Z', 'b': 'essai'}}, 'doc_type': 'A'})

a.d['essai'] = "test"
self.assert_(a.d == {'essai': 'test',
'test': {'a': datetime(2009, 5, 10, 21, 19, 21, 127380),
'test': {'a': datetime(2009, 5, 10, 21, 19, 21),
'b': 'essai'}}
)
self.assert_(a._doc == {'d': {'essai': 'test', 'test': {'a': '2009-05-10T21:19:21.127380Z', 'b': 'essai'}},
self.assert_(a._doc == {'d': {'essai': 'test', 'test': {'a': '2009-05-10T21:19:21Z', 'b': 'essai'}},
'doc_type': 'A'})

del a.d['test']['a']
Expand Down Expand Up @@ -1618,8 +1618,8 @@ class A(Document):

d = datetime(2009, 4, 13, 22, 56, 10, 967388)
a.d['date'] = d
self.assert_(a.d['date'] == datetime(2009, 4, 13, 22, 56, 10, 967388))
self.assert_(a._doc == {'doc_type': 'A', 'd': { 'date': '2009-04-13T22:56:10.967388Z' }})
self.assert_(a.d['date'] == datetime(2009, 4, 13, 22, 56, 10))
self.assert_(a._doc == {'doc_type': 'A', 'd': { 'date': '2009-04-13T22:56:10Z' }})
a.save()

class A2(Document):
Expand All @@ -1637,18 +1637,18 @@ class A(Document):
a.d = {}

a.d['test'] = { 'a': datetime(2009, 5, 10, 21, 19, 21, 127380) }
self.assert_(a.d == {'test': {'a': datetime(2009, 5, 10, 21, 19, 21, 127380)}})
self.assert_(a._doc == {'d': {'test': {'a': '2009-05-10T21:19:21.127380Z'}}, 'doc_type': 'A'} )
self.assert_(a.d == {'test': {'a': datetime(2009, 5, 10, 21, 19, 21)}})
self.assert_(a._doc == {'d': {'test': {'a': '2009-05-10T21:19:21Z'}}, 'doc_type': 'A'} )

a.d['test']['b'] = "essai"
self.assert_(a._doc == {'d': {'test': {'a': '2009-05-10T21:19:21.127380Z', 'b': 'essai'}}, 'doc_type': 'A'})
self.assert_(a._doc == {'d': {'test': {'a': '2009-05-10T21:19:21Z', 'b': 'essai'}}, 'doc_type': 'A'})

a.d['essai'] = "test"
self.assert_(a.d == {'essai': 'test',
'test': {'a': datetime(2009, 5, 10, 21, 19, 21, 127380),
'test': {'a': datetime(2009, 5, 10, 21, 19, 21),
'b': 'essai'}}
)
self.assert_(a._doc == {'d': {'essai': 'test', 'test': {'a': '2009-05-10T21:19:21.127380Z', 'b': 'essai'}},
self.assert_(a._doc == {'d': {'essai': 'test', 'test': {'a': '2009-05-10T21:19:21Z', 'b': 'essai'}},
'doc_type': 'A'})

del a.d['test']['a']
Expand All @@ -1658,10 +1658,10 @@ class A(Document):
a.d['test']['essai'] = { "a": datetime(2009, 5, 10, 21, 21, 11, 425782) }
self.assert_(a.d == {'essai': 'test',
'test': {'b': 'essai',
'essai': {'a': datetime(2009, 5, 10, 21, 21, 11, 425782)}}}
'essai': {'a': datetime(2009, 5, 10, 21, 21, 11)}}}
)
self.assert_(a._doc == {'d': {'essai': 'test',
'test': {'b': 'essai', 'essai': {'a': '2009-05-10T21:21:11.425782Z'}}},
'test': {'b': 'essai', 'essai': {'a': '2009-05-10T21:21:11Z'}}},
'doc_type': 'A'}
)

Expand Down Expand Up @@ -1729,32 +1729,32 @@ class A(Document):
a.l.append(1)
a.l.append(datetime(2009, 5, 12, 13, 35, 9, 425701))
a.l.append({ 's': "test"})
self.assert_(a.l == [1, datetime(2009, 5, 12, 13, 35, 9, 425701), {'s': 'test'}])
self.assert_(a._doc == {'doc_type': 'A', 'l': [1, '2009-05-12T13:35:09.425701Z', {'s': 'test'}]}
self.assert_(a.l == [1, datetime(2009, 5, 12, 13, 35, 9), {'s': 'test'}])
self.assert_(a._doc == {'doc_type': 'A', 'l': [1, '2009-05-12T13:35:09Z', {'s': 'test'}]}
)
a.l[2]['date'] = datetime(2009, 5, 12, 13, 35, 9, 425701)
self.assertEqual(a._doc, {'doc_type': 'A',
self.assert_(a._doc == {'doc_type': 'A',
'l': [1,
'2009-05-12T13:35:09.425701Z',
{'date': '2009-05-12T13:35:09.425701Z', 's': 'test'}]}
'2009-05-12T13:35:09Z',
{'date': '2009-05-12T13:35:09Z', 's': 'test'}]}
)
a.save()

a1 = A.get(a._id)
self.assert_(a1.l == [1,
datetime(2009, 5, 12, 13, 35, 9, 425701),
{u'date': datetime(2009, 5, 12, 13, 35, 9, 425701), u's': u'test'}]
datetime(2009, 5, 12, 13, 35, 9),
{u'date': datetime(2009, 5, 12, 13, 35, 9), u's': u'test'}]
)

a.l[2]['s'] = 'test edited'
self.assert_(a.l == [1,
datetime(2009, 5, 12, 13, 35, 9, 425701),
{'date': datetime(2009, 5, 12, 13, 35, 9, 425701),
datetime(2009, 5, 12, 13, 35, 9),
{'date': datetime(2009, 5, 12, 13, 35, 9),
's': 'test edited'}]
)
self.assert_(a._doc['l'] == [1,
'2009-05-12T13:35:09.425701Z',
{'date': '2009-05-12T13:35:09.425701Z', 's': 'test edited'}]
'2009-05-12T13:35:09Z',
{'date': '2009-05-12T13:35:09Z', 's': 'test edited'}]
)


Expand Down

0 comments on commit 306a5b4

Please sign in to comment.