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