15 lines
811 B
Python
15 lines
811 B
Python
|
|
import unittest
|
||
|
|
from generate_scanner_routes import replace_scanner_actions
|
||
|
|
|
||
|
|
class ScannerGenerationTest(unittest.TestCase):
|
||
|
|
def test_repeat_generation_removes_duplicate_first_added_action_and_keeps_supplement(self):
|
||
|
|
source=' SCANNER_BATTERY("old"),\n SCANNER_INITIALIZE("old"),\n SCANNER_BATTERY("new"),\n SCANNER_SUPPLEMENT_PREPARE("keep"),\n MOTOR_MOVE("keep"),\n'
|
||
|
|
actions=' SCANNER_INITIALIZE("new"),\n SCANNER_BATTERY("new"),\n'
|
||
|
|
once=replace_scanner_actions(source,actions)
|
||
|
|
self.assertEqual(once,replace_scanner_actions(once,actions))
|
||
|
|
self.assertEqual(once.count('SCANNER_BATTERY('),1)
|
||
|
|
self.assertIn('SCANNER_SUPPLEMENT_PREPARE("keep")',once)
|
||
|
|
self.assertIn('MOTOR_MOVE("keep")',once)
|
||
|
|
|
||
|
|
if __name__=='__main__':unittest.main()
|