121
121
def test_find_candidates_old_buildvars(self):
122
122
with temp_dir() as root:
123
candidates_path = get_candidates_path(root)
124
os.mkdir(candidates_path)
125
master_path = os.path.join(candidates_path, 'master')
126
os.mkdir(master_path)
127
buildvars_path = os.path.join(master_path, 'buildvars.json')
128
open(buildvars_path, 'w')
123
_, buildvars_path = self.make_candidates_dir(root, 'master')
129
124
a_week_ago = time() - timedelta(days=7, seconds=1).total_seconds()
130
125
os.utime(buildvars_path, (time(), a_week_ago))
131
126
self.assertEqual(list(find_candidates(root)), [])
133
128
def test_find_candidates_artifacts(self):
134
129
with temp_dir() as root:
135
candidates_path = get_candidates_path(root)
130
self.make_candidates_dir(root, 'master-artifacts')
131
self.assertEqual(list(find_candidates(root)), [])
133
def test_find_candidates_find_all(self):
134
with temp_dir() as root:
135
master_path, buildvars_path = self.make_candidates_dir(
137
master_path_2, _ = self.make_candidates_dir(root, '1.24')
138
a_week_ago = time() - timedelta(days=7, seconds=1).total_seconds()
139
os.utime(buildvars_path, (time(), a_week_ago))
140
self.assertItemsEqual(list(find_candidates(root)), [master_path_2])
141
self.assertItemsEqual(list(find_candidates(root, find_all=True)),
142
[master_path, master_path_2])
144
def make_candidates_dir(self, root, master_name):
145
candidates_path = get_candidates_path(root)
146
if not os.path.isdir(candidates_path):
136
147
os.mkdir(candidates_path)
137
master_path = os.path.join(candidates_path, 'master-artifacts')
138
os.mkdir(master_path)
139
open(os.path.join(master_path, 'buildvars.json'), 'w')
140
self.assertEqual(list(find_candidates(root)), [])
148
master_path = os.path.join(candidates_path, master_name)
149
os.mkdir(master_path)
150
buildvars_path = os.path.join(master_path, 'buildvars.json')
151
open(buildvars_path, 'w')
152
return master_path, buildvars_path
143
155
class TestWaitForPort(TestCase):