class HumanizeOperationTest(unittest.TestCase): def setUp(self): tags = {'title': 'One_love', 'artist': 'bob marley', 'album': 'EXODUS'} self.song = Mock() self.song.__getitem__ = Mock(side_effect=lambda tag: tags[tag]) self.song.__setitem__ = Mock() self.song.__contains__ = Mock() self.humanize_operation = HumanizeOperation() def test_apply(self): self.humanize_operation.apply(self.song) expected_setitem_calls = [ call('title', 'One Love'), call('artist', 'Bob Marley'), call('album', 'Exodus') ] actual_setitem_calls = self.song.__setitem__.call_args_list for expected_call in expected_setitem_calls: self.assertTrue(expected_call in actual_setitem_calls) expected_contains_calls = [ call('title'), call('artist'), call('album') ] actual_contains_calls = self.song.__contains__.call_args_list for expected_call in expected_contains_calls: self.assertTrue(expected_call in actual_contains_calls)
class HumanizeOperationTest(unittest.TestCase): def setUp(self): tags = {'title': 'One_love', 'artist': 'bob marley', 'album': 'EXODUS'} self.song = Mock() self.song.__getitem__ = Mock(side_effect=lambda tag: tags[tag]) self.song.__setitem__ = Mock() self.song.__contains__ = Mock() self.humanize_operation = HumanizeOperation() def test_apply(self): self.humanize_operation.apply(self.song) expected_setitem_calls = [call('title', 'One Love'), call('artist', 'Bob Marley'), call('album', 'Exodus')] actual_setitem_calls = self.song.__setitem__.call_args_list for expected_call in expected_setitem_calls: self.assertTrue(expected_call in actual_setitem_calls) expected_contains_calls = [call('title'), call('artist'), call('album')] actual_contains_calls = self.song.__contains__.call_args_list for expected_call in expected_contains_calls: self.assertTrue(expected_call in actual_contains_calls)
def setUp(self): tags = {'title': 'One_love', 'artist': 'bob marley', 'album': 'EXODUS'} self.song = Mock() self.song.__getitem__ = Mock(side_effect=lambda tag: tags[tag]) self.song.__setitem__ = Mock() self.song.__contains__ = Mock() self.humanize_operation = HumanizeOperation()
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())