class TestFilterChangesets(unittest.TestCase):
    def setUp(self):
        self.changesets = [Changeset(filepaths=['test']),
                           Changeset(filepaths=['test'], epochTime=OCT_2_1980_EPOCH),
                           Changeset(filepaths=['test'], branch='another branch'),
                           Changeset(filepaths=['code'])]

        self.fickle = Fickle('.')
        self.fickle.changesets = lambda: self.changesets

    def test_no_filters_returns_all_changesets(self):
        self.assertEquals(self.changesets, self.fickle.filter_changesets([]))

    def test_one_filter_returns_changsets_passing_that_filter(self):
        changesetsOnDefault = self.changesets[0:2] + self.changesets[3:4]
        self.assertEquals(changesetsOnDefault, self.fickle.filter_changesets([on_default]))

    def test_two_filters_returns_changesets_passing_both(self):
        changesetsOnDefaultAndTDDed = self.changesets[:2]
        self.assertEquals(changesetsOnDefaultAndTDDed, self.fickle.filter_changesets([is_tdded, on_default]))

    def test_three_filters_returns_changets_passing_all(self):
        changesetsOnDefaultAndTDDedSinceOct31980 = self.changesets[:1]

        filters = [is_tdded, on_default, after_date(OCT_3_1980_DATE)]
        self.assertEquals(changesetsOnDefaultAndTDDedSinceOct31980, self.fickle.filter_changesets(filters))
class TestGetChangesets(unittest.TestCase):
    def setUp(self):
        os.mkdir('repo')
        self.repo_path = os.getcwd() + '/repo'
        self.repo = Repository(hg.repository(ui.ui(), self.repo_path, True))
        self.fickle = Fickle(os.getcwd() + '/repo')

    def tearDown(self):
        shutil.rmtree('repo')

    def test_empty_repository_returns_generator_with_0_changesets(self):
        self.assertEqual(0, len_generator(self.fickle.changesets()))

    def test_repository_with_one_changeset_returns_the_changeset(self):
        self.repo.commit_files(['repo/first_file'])

        self.assertEqual(1, len_generator(self.fickle.changesets()))

    def test_repository_with_two_changesets_returns_two_changesets(self):
        self.repo.commit_files(['repo/first_file'])
        self.repo.commit_files(['repo/second_file'])

        self.assertEqual(2, len_generator(self.fickle.changesets()))

    def test_changesets_are_returned_in_commit_order(self):
        self.repo.commit_files(['repo/first_file'])
        self.repo.commit_files(['repo/second_file'])

        changesets = self.fickle.changesets()
        self.assertEqual(['first_file'], changesets.next().files())
        self.assertEqual(['second_file'], changesets.next().files())
class TestGetChangesets(unittest.TestCase):
    def setUp(self):
        os.mkdir('repo')
        self.repo_path = os.getcwd() + '/repo'
        self.repo = Repository(hg.repository(ui.ui(), self.repo_path, True))
        self.fickle = Fickle(os.getcwd() + '/repo')
    
    def tearDown(self):
        shutil.rmtree('repo')

    def test_empty_repository_returns_generator_with_0_changesets(self):
        self.assertEqual(0, len_generator(self.fickle.changesets()))

    def test_repository_with_one_changeset_returns_the_changeset(self):
        self.repo.commit_files(['repo/first_file'])

        self.assertEqual(1, len_generator(self.fickle.changesets()))

    def test_repository_with_two_changesets_returns_two_changesets(self):
        self.repo.commit_files(['repo/first_file'])
        self.repo.commit_files(['repo/second_file'])

        self.assertEqual(2, len_generator(self.fickle.changesets()))

    def test_changesets_are_returned_in_commit_order(self):
        self.repo.commit_files(['repo/first_file'])
        self.repo.commit_files(['repo/second_file'])
        
        changesets = self.fickle.changesets()
        self.assertEqual(['first_file'], changesets.next().files())
        self.assertEqual(['second_file'], changesets.next().files())
Example #4
0
class TestFilterChangesets(unittest.TestCase):
    def setUp(self):
        self.changesets = [Changeset(filepaths=['test']),
                           Changeset(filepaths=['test'], epochTime=OCT_2_1980_EPOCH),
                           Changeset(filepaths=['test'], branch='another branch'),
                           Changeset(filepaths=['code'])]

        self.fickle = Fickle('.')
        self.fickle.changesets = lambda: self.changesets

    def test_no_filters_returns_all_changesets(self):
        self.assertEquals(self.changesets, self.fickle.filter_changesets([]))

    def test_one_filter_returns_changsets_passing_that_filter(self):
        changesetsOnDefault = self.changesets[0:2] + self.changesets[3:4]
        self.assertEquals(changesetsOnDefault, self.fickle.filter_changesets([OnBranch('default')]))

    def test_two_filters_returns_changesets_passing_both(self):
        changesetsOnDefaultAndTDDed = self.changesets[:2]
        self.assertEquals(changesetsOnDefaultAndTDDed, self.fickle.filter_changesets([IsTdded(), OnBranch('default')]))

    def test_three_filters_returns_changets_passing_all(self):
        changesetsOnDefaultAndTDDedSinceOct31980 = self.changesets[:1]

        filters = [IsTdded(), OnBranch('default'), AfterDate(OCT_3_1980_DATE)]
        self.assertEquals(changesetsOnDefaultAndTDDedSinceOct31980, self.fickle.filter_changesets(filters))
def generate_and_display_metrics():
    repo = Fickle(os.getcwd())
    if not repo.is_valid():
        print('There is no repository at %s' % os.getcwd())
        return
    
    print_metrics(repo)
Example #6
0
    def setUp(self):
        self.changesets = [Changeset(filepaths=['test']),
                           Changeset(filepaths=['test'], epochTime=OCT_2_1980_EPOCH),
                           Changeset(filepaths=['test'], branch='another branch'),
                           Changeset(filepaths=['code'])]

        self.fickle = Fickle('.')
        self.fickle.changesets = lambda: self.changesets
class TestFickleIsEmpty(unittest.TestCase):
    def setUp(self):
        os.mkdir('repo')
        repo_dir = os.getcwd() + '/repo'

        self.repo = Repository(hg.repository(ui.ui(), repo_dir, create=True))
        self.fickle = Fickle(repo_dir)

    def tearDown(self):
        shutil.rmtree('repo')

    def test_repository_with_no_changesets_is_empty(self):
        self.assertTrue(self.fickle.is_empty())

    def test_repository_with_one_changeset_is_not_empty(self):
        self.repo.commit_files(['repo/testfile'])
        self.assertFalse(self.fickle.is_empty())
class TestFickleIsEmpty(unittest.TestCase):
    def setUp(self):
        os.mkdir('repo')
        repo_dir = os.getcwd() + '/repo'
            
        self.repo = Repository(hg.repository(ui.ui(), repo_dir, create=True))
        self.fickle = Fickle(repo_dir)

    def tearDown(self):
        shutil.rmtree('repo')

    def test_repository_with_no_changesets_is_empty(self):
        self.assertTrue(self.fickle.is_empty())

    def test_repository_with_one_changeset_is_not_empty(self):
        self.repo.commit_files(['repo/testfile']) 
        self.assertFalse(self.fickle.is_empty())
    def setUp(self):
        self.changesets = [Changeset(filepaths=['test']),
                           Changeset(filepaths=['test'], epochTime=OCT_2_1980_EPOCH),
                           Changeset(filepaths=['test'], branch='another branch'),
                           Changeset(filepaths=['code'])]

        self.fickle = Fickle('.')
        self.fickle.changesets = lambda: self.changesets
Example #10
0
def generate_and_display_metrics():
    repo = Fickle(os.getcwd())
    args = parse_arguments(sys.argv)
    base_filters = get_filters_from_args(args)
    metrics_filter = IsTdded()

    if not args.byMonth:
        print_metrics(repo, base_filters, metrics_filter, DefaultOutput())
    else:
        monthly_metrics(repo, base_filters, metrics_filter, MonthlyOutput())
 def setUp(self):
     os.mkdir('repo')
     self.repo_path = os.getcwd() + '/repo'
     self.repo = Repository(hg.repository(ui.ui(), self.repo_path, True))
     self.fickle = Fickle(os.getcwd() + '/repo')
 def setUp(self):
     os.mkdir('repo')
     self.repo_path = os.getcwd() + '/repo'
     self.repo = Repository(hg.repository(ui.ui(), self.repo_path, True))
     self.fickle = Fickle(os.getcwd() + '/repo')
    def setUp(self):
        os.mkdir('repo')
        repo_dir = os.getcwd() + '/repo'

        self.repo = Repository(hg.repository(ui.ui(), repo_dir, create=True))
        self.fickle = Fickle(repo_dir)
 def test_repository_is_valid(self):
     hg.repository(ui.ui(), self.repo_dir, create=True)
     self.assertTrue(Fickle(self.repo_dir).is_valid())
 def test_no_repository_is_not_valid(self):
     self.assertFalse(Fickle(self.repo_dir).is_valid())
 def setUp(self):
     os.mkdir('repo')
     repo_dir = os.getcwd() + '/repo'
         
     self.repo = Repository(hg.repository(ui.ui(), repo_dir, create=True))
     self.fickle = Fickle(repo_dir)