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_2_changesets_in_2_months(self): changesets = [ Changeset(epochTime=OCT_1980_EPOCH), Changeset(epochTime=NOV_1980_EPOCH) ] monthly = group_by_month(changesets) months = [] changes = [] for k, g in monthly: months.append(k) changes.append(list(g)) self.assertEquals(2, len(months)) self.assertEquals('1980-10', months[0]) self.assertEquals('1980-11', months[1]) self.assertEquals(2, len(changes)) self.assertEquals(1, len(changes[0])) self.assertEquals(1, len(changes[1]))
def test_only_code_file_is_not_tdded(self): self.assertFalse(self.testedFilter(Changeset(filepaths=['filecode'])))
def test_not_matching_user_returns_false(self): self.assertFalse(ByUsers(['A User'])(Changeset(user='******')))
def test_matching_user_returns_true(self): self.assertTrue(ByUsers(['A User'])(Changeset(user='******')))
def test_partial_matches(self): self.assertTrue(ByUsers(['user'])(Changeset(user='******')))
def test_any_matching_user_passes(self): self.assertTrue( ByUsers(['A User', 'B User'])(Changeset(user='******')))
def test_matching_extension_must_be_at_end_preceeded_by_point(self): self.assertFalse(ByExtensions(['cpp'])(Changeset(['noextensioncpp'])))
def test_case_insensitive(self): self.assertTrue(ByUsers(['A USER'])(Changeset(user='******')))
def test_default_branch_returns_true(self): self.assertTrue(self.default_filter(Changeset(branch='default')))
def test_filter_branch_other_than_default(self): self.assertTrue(self.other_filter(Changeset(branch='other')))
def test_only_test_file_is_considered_tdded(self): self.assertTrue(self.testedFilter(Changeset(filepaths=['filetest'])))
def test_does_not_care_about_case(self): self.assertTrue(self.testedFilter(Changeset(filepaths=['FILETEST'])))
def test_changeset_exactly_on_date_false(self): after_date_filter = AfterDate(self.OCT_3_1980_DATE) self.assertFalse( after_date_filter(Changeset(epochTime=self.OCT_3_1980_EPOCH)))
def test_changeset_after_date_true(self): after_date_filter = AfterDate(self.OCT_2_1980_DATE) self.assertTrue( after_date_filter(Changeset(epochTime=self.OCT_3_1980_EPOCH)))
def test_matching_extensions_returns_true(self): self.assertTrue(ByExtensions(['h'])(Changeset(['headerfile.h'])))
def test_not_matching_extension_returns_false(self): self.assertFalse(ByExtensions(['cpp'])(Changeset(['script.py'])))
def test_matches_with_any_of_multiple_extensions(self): self.assertTrue(ByExtensions(['py', 'cpp'])(Changeset(['codefile.cpp'])))
def test_other_branch_returns_false(self): self.assertFalse(self.default_filter(Changeset(branch='other')))
def test_code_and_test_testedFilter(self): self.assertTrue( self.testedFilter(Changeset(filepaths=['filecode', 'testcode'])))
def test_no_file_changes_is_not_tdd(self): self.assertFalse(self.testedFilter(Changeset(filepaths=[])))
def test_will_match_any_of_multiple_files(self): self.assertTrue(ByExtensions(['py'])(Changeset(['codefile.cpp', 'script.py'])))