Esempio n. 1
0
 def test_to_dict(self):
     ship1 = Ship('1', Location(1, 2), 90, 8, 6)
     ship2 = Ship('2', Location(1, 2), 90, 12, 4)
     environment = Environment(300, 200, [ship1, ship2])
     expected = {
         'width': 300,
         'height': 200,
         'ships': [ship1.to_dict(), ship2.to_dict()]
     }
     self.assertEqual(expected, environment.to_dict())
Esempio n. 2
0
 def test_from_dict(self):
     ship1 = Ship('1', Location(1, 2), 90, 8, 6)
     ship2 = Ship('2', Location(1, 2), 90, 12, 4)
     environment = Environment(300, 200, [ship1, ship2])
     self.assertEqual(environment,
                      Environment.from_dict(environment.to_dict()))