def test_the_same(self): self.settings.parse_args('target {}'.format(self.file1_data)) cmd = CmdTarget(self.settings) self.assertEqual(cmd.run(), 0) self.assertEqual(open('.target').read(), self.file1_data) self.assertEqual(cmd.run(), 0) self.assertEqual(open('.target').read(), self.file1_data)
def test_multiple_files(self): self.settings.parse_args('target {}'.format(self.file1_data)) cmd = CmdTarget(self.settings) cmd.run() # Another target self.settings.parse_args('target {}'.format(self.file2_data)) cmd = CmdTarget(self.settings) self.assertEqual(cmd.run(), 0) self.assertEqual(open('.target').read(), self.file2_data) # Unset target self.settings.parse_args('target --unset') cmd = CmdTarget(self.settings) self.assertEqual(cmd.run(), 0) self.assertEqual(open('.target').read(), '')
def test_unset_existing_target(self): self.settings.parse_args('target {}'.format(self.file1_data)) cmd = CmdTarget(self.settings) self.assertEqual(cmd.run(), 0) self.assertEqual(open('.target').read(), self.file1_data) self.settings.parse_args('target --unset') cmd = CmdTarget(self.settings) self.assertEqual(cmd.run(), 0) self.assertEqual(open('.target').read(), '')
def test_args_conflict(self): self.settings.parse_args('target {} --unset'.format(self.file1_data)) cmd = CmdTarget(self.settings) self.assertEqual(cmd.run(), 1)
def test_initial_unset(self): self.settings.parse_args('target --unset') cmd = CmdTarget(self.settings) self.assertEqual(cmd.run(), 1) self.assertFalse(os.path.exists('.target'))
def test_no_args(self): self.settings.parse_args('target --unset') cmd = CmdTarget(self.settings) self.assertEqual(cmd.run(), 1)