Пример #1
0
	def test_SimpleLine(self):
		item1 = ItemStack(1, 1)
		item2 = ItemStack(2, 1)
		item3 = ItemStack(3, 1)
		bluePrint1 = Blueprint(1, "", None, [item2], item1)
		refine1 = Refine(1, "", None, item3, [item2])

		toolkitMock = Mock()
		toolkitMock.GetTypePixmap = Mock(return_value=QPixmap())
		line = Line(bluePrint1, toolkitMock)
		line.AddProcess(refine1)
		self.assertEqual(len(line.balance), 2)
		self.assertEqual(line.balance[0].itemId, 1)
		self.assertEqual(line.balance[0].ammount, 1)
		self.assertEqual(line.balance[1].itemId, 3)
		self.assertEqual(line.balance[1].ammount, -1)
Пример #2
0
	def test_ConstructMultipleOutputsTree(self):
		tookitMock = Mock()
		tookitMock.GetTypePixmap = Mock(return_value=QPixmap())

		graphics = []
		graphics.append(ProcessGraphic(Process(DummyBlueprint([3, 4], 5)), tookitMock))
		graphics.append(ProcessGraphic(Process(DummyRefine(2, [3])), tookitMock))
		graphics.append(ProcessGraphic(Process(DummyRefine(1, [3, 4])), tookitMock))

		GetProcessGraphicPositions(graphics)

		assert graphics[0].col == 0
		assert graphics[0].row == 0
		assert graphics[1].col == 1
		assert graphics[1].row == 0
		assert graphics[2].col == 1
		assert graphics[2].row == 1
Пример #3
0
	def test_ConstructTree(self):
		tookitMock = Mock()
		tookitMock.GetTypePixmap = Mock(return_value=QPixmap())

		graphics = []
		graphics.append(ProcessGraphic(Process(DummyBlueprint([2, 3], 4)), tookitMock))
		graphics.append(ProcessGraphic(Process(DummyBlueprint([1], 2)), tookitMock))
		graphics.append(ProcessGraphic(Process(DummyBlueprint([1], 3)), tookitMock))

		GetProcessGraphicPositions(graphics)
		
		assert graphics[0].col == 0
		assert graphics[0].row == 0
		assert graphics[1].col == 1
		assert graphics[1].row == 0
		assert graphics[2].col == 1
		assert graphics[2].row == 1
Пример #4
0
	def test_BalanceOreRefine(self):
		bantamBlueprint = Blueprint(1, "", None,
			[		
			ItemStack(34, 22222),
			ItemStack(35, 8000 ),
			ItemStack(36, 2444 ),
			ItemStack(37, 500  ),
			ItemStack(38, 2    ),
			ItemStack(39, 2    ),
			],
			ItemStack(582, 1))
				
		omber = Refine(2, "", None,
			ItemStack(1227, 100),
			[
			ItemStack(34, 85),
			ItemStack(35, 34),
			ItemStack(37, 85),
			])
		
		plagioclase = Refine(3, "", None,
			ItemStack(18, 100),
			[
			ItemStack(34, 107),
			ItemStack(35, 213),
			ItemStack(36, 107),
			])
		
		scordite = Refine(4, "", None,
			ItemStack(1228, 100),
			[
			ItemStack(34, 346),
			ItemStack(35, 173),
			])

		toolkitMock = Mock()
		toolkitMock.GetTypePixmap = Mock(return_value=QPixmap())
		line = Line(bantamBlueprint, toolkitMock)
		line.AddProcess(omber)
		line.AddProcess(plagioclase)
		line.AddProcess(scordite)
		line.Balance()
		self.assertGreater(line.processes[1].runs, 1)
		self.assertGreater(line.processes[2].runs, 1)
		self.assertGreater(line.processes[3].runs, 1)
Пример #5
0
	def test_ConstructProgramm(self):
		ORE = 1
		MINERAL = 2
		PART = 3
		SHIP = 4

		refine = Refine(1, "", None, ItemStack(ORE, 1), [ItemStack(MINERAL, 50)])
		blueprint1 = Blueprint(1, "", None, [ItemStack(MINERAL, 10)], ItemStack(PART, 1))
		blueprint2 = Blueprint(2, "", None, [ItemStack(MINERAL, 100), ItemStack(PART, 3)], ItemStack(SHIP, 1) )

		toolkitMock = Mock()
		toolkitMock.GetTypePixmap = Mock(return_value=QPixmap())
		line = Line(blueprint2, toolkitMock)
		line.AddProcess(refine)
		line.AddProcess(blueprint1)
		c, Aub, bub, Aeq, beq  = line.ConstructLinearProgramm()
		self.assertEqual(c, [1, 1, 1])
		self.assertEqual(Aub, [[100, -50, 10], [3, 0, -1]])
		self.assertEqual(bub, [0, 0])
		self.assertEqual(Aeq, [[1, 0, 0]])
		self.assertEqual(beq, [1])