Code Duplication    Length = 26-28 lines in 2 locations

doorstop/cli/test/test_all.py 2 locations

@@ 370-397 (lines=28) @@
367
        self.assertRaises(SystemExit, main, ['link', 'tut3', 'req9999'])
368
369
370
@unittest.skipUnless(os.getenv(ENV), REASON)
371
@patch('doorstop.settings.ADDREMOVE_FILES', False)
372
class TestUnlink(unittest.TestCase):
373
    """Integration tests for the 'doorstop unlink' command."""
374
375
    ITEM = os.path.join(TUTORIAL, 'TUT003.yml')
376
377
    def setUp(self):
378
        self.backup = common.read_text(self.ITEM)
379
        with patch('doorstop.settings.ADDREMOVE_FILES', False):
380
            main(['link', 'tut3', 'req2'])  # create a temporary link
381
382
    def tearDown(self):
383
        common.write_text(self.backup, self.ITEM)
384
385
    def test_unlink(self):
386
        """Verify 'doorstop unlink' can be called."""
387
        self.assertIs(None, main(['unlink', 'tut3', 'req2']))
388
389
    def test_unlink_unknown_child(self):
390
        """Verify 'doorstop unlink' returns an error with an unknown child."""
391
        self.assertRaises(SystemExit, main, ['unlink', 'unknown3', 'req2'])
392
        self.assertRaises(SystemExit, main, ['link', 'tut9999', 'req2'])
393
394
    def test_unlink_unknown_parent(self):
395
        """Verify 'doorstop unlink' returns an error with an unknown parent."""
396
        self.assertRaises(SystemExit, main, ['unlink', 'tut3', 'unknown2'])
397
        self.assertRaises(SystemExit, main, ['unlink', 'tut3', 'req9999'])
398
399
400
@unittest.skipUnless(os.getenv(ENV), REASON)
@@ 342-367 (lines=26) @@
339
        self.assertRaises(SystemExit, main, ['edit', 'req9999'])
340
341
342
@unittest.skipUnless(os.getenv(ENV), REASON)
343
@patch('doorstop.settings.ADDREMOVE_FILES', False)
344
class TestLink(unittest.TestCase):
345
    """Integration tests for the 'doorstop link' command."""
346
347
    ITEM = os.path.join(TUTORIAL, 'TUT003.yml')
348
349
    def setUp(self):
350
        self.backup = common.read_text(self.ITEM)
351
352
    def tearDown(self):
353
        common.write_text(self.backup, self.ITEM)
354
355
    def test_link(self):
356
        """Verify 'doorstop link' can be called."""
357
        self.assertIs(None, main(['link', 'tut3', 'req2']))
358
359
    def test_link_unknown_child(self):
360
        """Verify 'doorstop link' returns an error with an unknown child."""
361
        self.assertRaises(SystemExit, main, ['link', 'unknown3', 'req2'])
362
        self.assertRaises(SystemExit, main, ['link', 'tut9999', 'req2'])
363
364
    def test_link_unknown_parent(self):
365
        """Verify 'doorstop link' returns an error with an unknown parent."""
366
        self.assertRaises(SystemExit, main, ['link', 'tut3', 'unknown2'])
367
        self.assertRaises(SystemExit, main, ['link', 'tut3', 'req9999'])
368
369
370
@unittest.skipUnless(os.getenv(ENV), REASON)