def test_if_sha_file_is_new__check_update__should_return_false(self): with open(self.sha_file, 'w+') as f: f.write(fancy_sha) self.assertEqual(viewer.check_update(), False) # check that SHA file not modified with open(self.sha_file, 'r') as f: self.assertEqual(f.readline(), fancy_sha)
def test_if_sha_file_is_empty__check_update__should_return_true(self, req_get): with open(self.sha_file, 'w+') as f: pass epoch = datetime.utcfromtimestamp(0) yesterday = datetime.now() - timedelta(days=2) dt = (yesterday - epoch).total_seconds() os.utime(self.sha_file, (dt, dt)) self.assertEqual(viewer.check_update(), True) # check that file contains latest SHA with open(self.sha_file, 'r') as f: self.assertNotEqual(f.readline(), '')
def test_if_sha_file_is_empty__check_update__should_return_true(self, req_get, remote_branch_available, fetch_remote_hash): with open(self.sha_file, 'w+') as f: pass epoch = datetime.utcfromtimestamp(0) yesterday = datetime.now() - timedelta(days=2) dt = (yesterday - epoch).total_seconds() os.utime(self.sha_file, (dt, dt)) self.assertEqual(viewer.check_update(), True) # check that file contains latest SHA with open(self.sha_file, 'r') as f: self.assertNotEqual(f.readline(), '')