class RenameOperationTest(unittest.TestCase): def setUp(self): self.song = Mock() self.template = Mock() self.rename_operation = RenameOperation(self.template) def test_apply(self): self.template.safe_substitute.return_value = ' a filename ' self.rename_operation.apply(self.song) self.template.safe_substitute.assert_called_with(self.song) self.assertEquals('a filename', self.song.filename)
def from_args(self, args): name = args.command if name == 'get': return GetCommand() elif name == 'set': return OperationCommand(SetOperation(args.__dict__)) elif name == 'rename': template = FreiTemplate(args.format) return OperationCommand(RenameOperation(template)) elif name == 'extract': template = FreiTemplate(args.format) return OperationCommand(ExtractOperation(template)) elif name == 'humanize': return OperationCommand(HumanizeOperation())
def setUp(self): self.song = Mock() self.template = Mock() self.rename_operation = RenameOperation(self.template)