mirror of
https://github.com/iluvcapra/mfbatch.git
synced 2025-12-31 08:50:51 +00:00
Test implementation
This commit is contained in:
@@ -1,19 +1,36 @@
|
||||
"mfbatch tests"
|
||||
|
||||
import unittest
|
||||
from unittest.mock import MagicMock
|
||||
from typing import cast
|
||||
|
||||
from mfbatch.commands import BatchfileParser
|
||||
from mfbatch.commands import BatchfileParser
|
||||
|
||||
class CommandTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.command_parser = BatchfileParser()
|
||||
self.command_parser.dry_run = False
|
||||
self.command_parser.write_metadata_f = MagicMock()
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testSetWithoutWrite(self):
|
||||
self.command_parser.set(['TYPE', 'Everything'])
|
||||
self.assertFalse(cast(MagicMock,
|
||||
self.command_parser.write_metadata_f).called)
|
||||
self.assertEqual(self.command_parser.env.metadatums['TYPE'],
|
||||
'Everything')
|
||||
|
||||
def testSetCommand(self):
|
||||
self.command_parser.set(['X', 'Y'])
|
||||
self.assertEqual(self.command_parser.env.metadatums['X'], 'Y')
|
||||
self.command_parser.eval("./testfile.flac", lineno=1,
|
||||
interactive=False)
|
||||
self.assertTrue(cast(MagicMock,
|
||||
self.command_parser.write_metadata_f).called)
|
||||
self.assertEqual(cast(MagicMock,
|
||||
self.command_parser.write_metadata_f).call_args.args,
|
||||
('./testfile.flac', {'X': 'Y'}))
|
||||
|
||||
def testUnsetCommand(self):
|
||||
self.command_parser.set(['A', '1'])
|
||||
|
||||
Reference in New Issue
Block a user