Esempio n. 1
0
    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)
Esempio n. 2
0
    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(), '')
Esempio n. 3
0
    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(), '')
Esempio n. 4
0
 def test_args_conflict(self):
     self.settings.parse_args('target {} --unset'.format(self.file1_data))
     cmd = CmdTarget(self.settings)
     self.assertEqual(cmd.run(), 1)
Esempio n. 5
0
 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'))
Esempio n. 6
0
 def test_no_args(self):
     self.settings.parse_args('target --unset')
     cmd = CmdTarget(self.settings)
     self.assertEqual(cmd.run(), 1)