def test_planet_init(): planet = Planet('foo') assert planet.getName() == 'foo' assert planet.getPlanetsInOwnOrbit() == [] assert planet.getInOrbitOf() == None planet2 = Planet('ABC') assert planet2.getName() == 'ABC' assert len(planet2.getPlanetsInOwnOrbit()) == 0 assert planet2.getInOrbitOf() == None
def test_putinorbitof(): """ Planet can put itself in orbit of one other planet """ planet = Planet('planet') the_other_planet = Planet('the other planet') planet.putInOrbitOf(the_other_planet) assert planet.getInOrbitOf() == the_other_planet another_planet = Planet('another planet') planet.putInOrbitOf(another_planet) assert planet.getInOrbitOf() == another_planet
def test_putinownorbit_linksinbothdirections(): """ If Planet B is set as putInOrbitOf() of Planet A, Planet A will putInOwnOrbit() Planet B. """ planetA = Planet('A') planetB = Planet('B') assert planetA.getPlanetsInOwnOrbit() == [] assert planetB.getInOrbitOf() == None planetB.putInOrbitOf(planetA) assert planetA.getPlanetsInOwnOrbit() == [planetB] assert planetB.getInOrbitOf() == planetA
def test_putinorbitof_linksinbothdirections(): """ If Planet B is put in orbit of Planet A, Planet A will be put as isInOrbitOf of Planet B. """ planetA = Planet('A') planetB = Planet('B') assert planetA.getPlanetsInOwnOrbit() == [] assert planetB.getInOrbitOf() == None planetA.putInOwnOrbit(planetB) assert planetA.getPlanetsInOwnOrbit() == [planetB] assert planetB.getInOrbitOf() == planetA