Test implementation

This commit is contained in:
Jamie Hardt
2024-07-07 15:15:01 -07:00
parent 0d765f9d84
commit d334181dc8
2 changed files with 22 additions and 4 deletions

View File

@@ -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'])