def test_return_basename_of_the_file_if_filename_is_set(self): """Return basename "/filename" field is set in GwyContainer""" gwyfile = Mock(spec=Gwyfile) pathname = "/home/user/data/sample.gwy" basename = "sample.gwy" gwyfile.get_gwyitem_string.return_value = pathname actual_return = GwyContainer._get_filename(gwyfile) self.assertEqual(actual_return, basename)
def test_return_None_if_filename_is_unset(self): """Return None if "/filename" field is unset in GwyContainer""" gwyfile = Mock(spec=Gwyfile) gwyfile.get_gwyitem_string.return_value = None actual_return = GwyContainer._get_filename(gwyfile) gwyfile.get_gwyitem_string.assert_has_calls( [call("/filename")]) self.assertIsNone(actual_return)