def test_key_parameter(self): """Ignore files_df if nothing in it is relevant""" self.log['component'] = 'kernel' actual = cm.get_ages(self.log, by=['component', 'kind']) expected = pd.read_csv( io.StringIO( textwrap.dedent(''' component,kind,age kernel,file,1.563889'''))) self.assertEqual(expected, actual)
def test_ages(self): """The age report generates data based on the SCM log data""" actual = cm.get_ages(self.log) expected = pd.read_csv( io.StringIO( textwrap.dedent(''' path,age requirements.txt,3.531817 stats.py,1.563889 '''))) self.assertEqual(expected, actual)
def test_ages_enriched_with_kind(self): """Allow to use additional columns in age report.""" actual = cm.get_ages(self.log, by=['path', 'kind'])[['path', 'kind', 'age']] expected = pd.read_csv( io.StringIO( textwrap.dedent(''' path,kind,age requirements.txt,file,3.531817 stats.py,file,1.563889 '''))) self.assertEqual(expected, actual)
def test_age_report_enriched_with_component(self): """Allow one to enrich the log before generating the age report.""" log = self.log log['component'] = 'blah' actual = cm.get_ages(log, by=['path', 'component']) expected = pd.read_csv( io.StringIO( textwrap.dedent(''' path,component,age requirements.txt,blah,3.531817 stats.py,blah,1.563889 '''))) self.assertEqual(expected, actual)
def test_key_parameter(self): """Ignore files_df if nothing in it is relevant""" self.log["component"] = "kernel" actual = cm.get_ages(self.log, by=["component", "kind"]) expected = pd.read_csv( io.StringIO( textwrap.dedent( """ component,kind,age kernel,file,1.563889""" ) ), dtype={"kind": "category"}, ) self.assertEqual(expected, actual)
def test_ages_when_revision_in_index(self): """Handle when inpput has path in index.""" actual = cm.get_ages(self.log.set_index(["revision", "path"])) self.assertEqual(self.expected, actual)
def test_ages_enriched_with_kind(self): """Allow to use additional columns in age report.""" actual = cm.get_ages(self.log, by=["path", "kind"])[["path", "age", "kind"]] self.assertEqual( self.expected.assign(kind="file").astype({"kind": "category"}), actual )
def test_ages(self): """The age report generates data based on the SCM log data""" actual = cm.get_ages(self.log) self.assertEqual(self.expected, actual)