<s> """<STR_LIT>""" <EOL> from os import path <EOL> from unittest import TestCase , expectedFailure <EOL> import pyDMCC <EOL> from bot . hardware . dmcc_motor import DMCCMotorSet , DMCCMotor <EOL> import bot . lib . lib as lib <EOL> class TestDMCCMotorSet ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> config = path . dirname ( path . realpath ( __file__ ) ) + "<STR_LIT>" <EOL> self . config = lib . get_config ( config ) <EOL> self . logger = lib . get_logger ( ) <EOL> self . logger . info ( "<STR_LIT>" . format ( self . _testMethodName ) ) <EOL> def test_instantiate ( self ) : <EOL> conf = { '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:1> } } <EOL> motor_set = DMCCMotorSet ( conf ) <EOL> self . assertIsInstance ( motor_set [ '<STR_LIT>' ] , DMCCMotor ) <EOL> def test_multiple_config ( self ) : <EOL> drive_conf = self . config [ '<STR_LIT>' ] <EOL> drive_motor_set = DMCCMotorSet ( drive_conf ) <EOL> self . assertEqual ( len ( drive_motor_set . motors ) , <NUM_LIT:4> ) <EOL> def test_bad_config ( self ) : <EOL> motor_conf = self . config [ '<STR_LIT>' ] <EOL> with self . assertRaises ( KeyError ) : <EOL> DMCCMotorSet ( motor_conf ) <EOL> class TestDMCCMotor ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> config = path . dirname ( path . realpath ( __file__ ) ) + "<STR_LIT>" <EOL> self . config = lib . get_config ( config ) <EOL> self . logger = lib . get_logger ( ) <EOL> self . logger . info ( "<STR_LIT>" . format ( self . _testMethodName ) ) <EOL> motor_conf = self . config [ '<STR_LIT>' ] <EOL> self . motor_set = DMCCMotorSet ( motor_conf ) <EOL> def test_instantiate ( self ) : <EOL> motor = self . motor_set [ '<STR_LIT>' ] <EOL> self . assertIsInstance ( motor , DMCCMotor ) <EOL> self . assertIsInstance ( motor . real_motor , pyDMCC . Motor ) <EOL> def test_set_power ( self ) : <EOL> """<STR_LIT>""" <EOL> motor = self . motor_set [ '<STR_LIT>' ] <EOL> motor . power = <NUM_LIT:0> <EOL> assert motor . power == <NUM_LIT:0> <EOL> motor . power = <NUM_LIT:50> <EOL> assert motor . power == <NUM_LIT:50> <EOL> def test_power_invert ( self ) : <EOL> """<STR_LIT>""" <EOL> motor_conf = self . config [ '<STR_LIT>' ] <EOL> motor_set = DMCCMotorSet ( motor_conf ) <EOL> normal = motor_set [ '<STR_LIT>' ] <EOL> inverted = motor_set [ '<STR_LIT>' ] <EOL> normal . power = <NUM_LIT> <EOL> self . assertEqual ( normal . _power , <NUM_LIT> ) <EOL> inverted . power = <NUM_LIT> <EOL> self . assertEqual ( inverted . _power , - <NUM_LIT> ) <EOL> def test_set_velocity_no_PID ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( RuntimeError ) : <EOL> self . motor_set [ '<STR_LIT>' ] . velocity = <NUM_LIT:0> <EOL> def test_set_velocity ( self ) : <EOL> """<STR_LIT>""" <EOL> motor = self . motor_set [ '<STR_LIT>' ] <EOL> motor . setVelocityPID ( <NUM_LIT:1000> , <NUM_LIT:100> , <NUM_LIT:10> ) <EOL> motor . velocity = <NUM_LIT:0> <EOL> assert motor . velocity == <NUM_LIT:0> <EOL> motor . velocity = <NUM_LIT:50> <EOL> assert motor . velocity == <NUM_LIT:50> <EOL> @ expectedFailure <EOL> def test_get_voltage ( self ) : <EOL> """<STR_LIT>""" <EOL> print self . dmcc_motor . dmcc . i2c <EOL> assert self . dmcc_motor . voltage == <NUM_LIT:0> </s>
