git @ Cat's Eye Technologies ellsync / 2d18d4b
Develop tests Chris Pressey 4 years ago
1 changed file(s) with 13 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
1212 def setUp(self):
1313 super(TestEllsync, self).setUp()
1414 self.saved_stdout = sys.stdout
15 self.saved_stderr = sys.stderr
1516 sys.stdout = StringIO()
17 sys.stderr = StringIO()
1618 self.maxDiff = None
1719 check_call("rm -rf canonical cache", shell=True)
1820 check_call("mkdir -p canonical", shell=True)
21 check_call("touch canonical/thing", shell=True)
1922 check_call("mkdir -p cache", shell=True)
2023 router = {
2124 'basic': {
2730 f.write(json.dumps(router))
2831
2932 def tearDown(self):
33 check_call("rm -rf canonical cache", shell=True)
3034 sys.stdout = self.saved_stdout
35 sys.stderr = self.saved_stderr
3136 super(TestEllsync, self).tearDown()
3237
3338 def test_failure(self):
3439 with self.assertRaises(SystemExit):
3540 main(['backup.json'])
3641
37 def test_basic(self):
42 def test_dry_run(self):
3843 main(['backup.json', 'canonical', 'cache'])
44 self.assertFalse(os.path.exists('cache/thing'))
45 output = sys.stdout.getvalue()
46 self.assertEqual(output, 'rsync --archive --verbose --delete canonical/ cache/\n')
47
48 def test_apply(self):
49 main(['backup.json', 'canonical', 'cache', '--apply'])
50 self.assertTrue(os.path.exists('cache/thing'))
3951
4052
4153 if __name__ == '__main__':