Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master

Add tests for dulwich.index.write_cache_time.

Changeset 41b91297de19

Parent cf5d5c4b6a61

by Jelmer Vernooij

Changes to one file · Browse files at 41b91297de19 Showing diff from parent cf5d5c4b6a61 Diff from another changeset...

 
1
2
 
 
3
4
5
 
20
21
22
 
 
 
23
24
 
25
26
27
 
29
30
31
 
32
33
34
 
123
124
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
 
20
21
22
23
24
25
26
27
28
29
30
31
 
33
34
35
36
37
38
39
 
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
@@ -1,5 +1,5 @@
-# test_index.py -- Tests for the git index cache -# Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org> +# test_index.py -- Tests for the git index +# Copyright (C) 2008-2009 Jelmer Vernooij <jelmer@samba.org>  #  # This program is free software; you can redistribute it and/or  # modify it under the terms of the GNU General Public License @@ -20,8 +20,12 @@
 """Tests for the index."""     +from cStringIO import ( + StringIO, + )  import os  import stat +import struct  from unittest import TestCase    from dulwich.index import ( @@ -29,6 +33,7 @@
  cleanup_mode,   commit_tree,   read_index, + write_cache_time,   write_index,   )  from dulwich.object_store import ( @@ -123,3 +128,25 @@
    def test_submodule(self):   self.assertEquals(0160000, cleanup_mode(0160744)) + + +class WriteCacheTimeTests(TestCase): + + def test_write_string(self): + f = StringIO() + self.assertRaises(TypeError, write_cache_time, f, "foo") + + def test_write_int(self): + f = StringIO() + write_cache_time(f, 434343) + self.assertEquals(struct.pack(">LL", 434343, 0), f.getvalue()) + + def test_write_tuple(self): + f = StringIO() + write_cache_time(f, (434343, 21)) + self.assertEquals(struct.pack(">LL", 434343, 21), f.getvalue()) + + def test_write_float(self): + f = StringIO() + write_cache_time(f, 434343.000000021) + self.assertEquals(struct.pack(">LL", 434343, 21), f.getvalue())