24
24
from lazygal.generators import WebalbumDir
25
25
from lazygal.sourcetree import Directory
26
26
from lazygal.genpage import WebalbumIndexPage
27
from lazygal import pyexiv2api as pyexiv2
30
29
class TestDeps(LazygalTestGen):
41
40
dest_path = os.path.join(self.tmpdir, 'dst')
42
41
dest_subgal = WebalbumDir(source_subgal, [], self.album, dest_path)
44
self.assertTrue(dest_subgal.needs_build(),
45
'Webalbum subgal has not been built and does not need build.')
44
dest_subgal.needs_build(),
45
'Webalbum subgal has not been built and does not need build.')
47
47
self.album.generate(dest_path)
48
48
dest_subgal = WebalbumDir(source_subgal, [], self.album, dest_path)
50
self.assertFalse(dest_subgal.needs_build(),
51
'Webalbum subgal has been built and does need build because of %s.'\
51
dest_subgal.needs_build(),
52
'Webalbum subgal has been built and does need build because of %s.'
52
53
% str(dest_subgal.needs_build(True)))
54
55
def test_dirmetadata_update(self):
72
73
self.album.generate(dest_path)
73
74
dest_subgal = WebalbumDir(source_subgal, [], self.album, dest_path)
75
self.assertFalse(dest_subgal.needs_build(),
76
'Webalbum subgal has been built and does need build because of %s.'\
77
dest_subgal.needs_build(),
78
'Webalbum subgal has been built and does need build because of %s.'
77
79
% str(dest_subgal.needs_build(True)))
79
81
# touch the description file
80
time.sleep(1) # ensure time diffrence for some systems
82
time.sleep(1) # ensure time diffrence for some systems
81
83
os.utime(os.path.join(source_subgal.path, 'album_description'), None)
82
84
# New objects in order to probe filesystem
83
85
source_subgal = Directory(subgal_path, [], ['subgal_img.jpg'],
85
87
dest_subgal = WebalbumDir(source_subgal, [], self.album, dest_path)
87
self.assertTrue(dest_subgal.needs_build(),
90
dest_subgal.needs_build(),
88
91
'Webalbum subgal should need build because of updated dir md.')
90
93
def test_subgal_update(self):
99
102
self.album.generate(dest_path)
100
103
dest_subgal = WebalbumDir(source_subgal, [], self.album, dest_path)
102
self.assertFalse(dest_subgal.needs_build(),
103
'Webalbum subgal has been built and does need build because of %s.'\
106
dest_subgal.needs_build(),
107
'Webalbum subgal has been built and does need build because of %s.'
104
108
% str(dest_subgal.needs_build(True)))
106
110
self.add_img(source_subgal.path, 'subgal_img2.jpg')
111
115
dest_subgal = WebalbumDir(source_subgal, [], self.album, dest_path)
113
117
# Subgal should need build.
114
self.assertTrue(dest_subgal.needs_build(),
119
dest_subgal.needs_build(),
115
120
'Webalbum subgal should need build because of added pic in subgal.')
117
122
# Parent directory should need build.
118
123
source_gal = Directory(self.source_dir, [source_subgal], [], self.album)
119
124
dest_gal = WebalbumDir(source_gal, [dest_subgal], self.album, dest_path)
120
self.assertTrue(dest_gal.needs_build(),
126
dest_gal.needs_build(),
121
127
'Webalbum gal should need build because of added pic in subgal.')
123
129
# Parent directory should need build.
124
130
parent_index = WebalbumIndexPage(dest_gal, 'small', 0,
126
132
[(dest_subgal, dest_subgal.medias)])
127
self.assertTrue(parent_index.needs_build(),
128
'Webalbum gal index should need build because of added pic in subgal.')
134
parent_index.needs_build(),
135
'Webalbum gal index should need build because of added pic in subgal.')
131
138
if __name__ == '__main__':