Esempio n. 1
0
	def setUp(self):
		super(InformationRunOrderTest, self).setUp()

		self.p2 = Player(game=self.g, secrets="Some nasty sfuff")
		self.p2.save()
		self.p2.citizenship.corporation = self.c
		self.p2.citizenship.save()

		from engine_modules.influence.models import BuyInfluenceOrder

		# Initial setup, create a resolution sheet we'll use later.
		o = BuyInfluenceOrder(
			player=self.p2
		)
		o.save()

		self.g.resolve_current_turn()

		self.io = InformationOrder(
			target=self.p2,
			player=self.p,
			additional_percents=0,
		)
		self.io.clean()
		self.io.save()

		self.set_to_zero(self.io.target.citizenship.corporation)
Esempio n. 2
0
class OrdersTest(EngineTestCase):
	def setUp(self):
		super(OrdersTest, self).setUp()
		self.o = BuyInfluenceOrder(
			player=self.p
		)
		self.o.clean()
		self.o.save()

	def test_order_cost_money(self):
		"""
		Money should be reduced
		"""
		self.g.resolve_current_turn()
		self.assertEqual(self.reload(self.p).money, self.initial_money - BuyInfluenceOrder.BASE_COST)

	def test_order_increment_influence(self):
		"""
		Order should increment influence
		"""
		self.g.resolve_current_turn()
		self.assertEqual(self.reload(self.p).influence.level, 2)

	def test_cant_create_order_twice(self):
		"""
		Order can't be created twice
		"""
		o2 = BuyInfluenceOrder(
			player=self.p
		)

		self.assertRaises(OrderNotAvailable, o2.clean)
Esempio n. 3
0
class OrdersTest(EngineTestCase):
    def setUp(self):
        super(OrdersTest, self).setUp()
        self.o = BuyInfluenceOrder(player=self.p)
        self.o.clean()
        self.o.save()

    def test_order_cost_money(self):
        """
		Money should be reduced
		"""
        self.o.resolve()

        self.assertEqual(
            self.reload(self.p).money,
            self.initial_money - BuyInfluenceOrder.BASE_COST * 2)

    def test_order_increment_influence(self):
        """
		Order should increment influence
		"""
        self.o.resolve()

        self.assertEqual(self.reload(self.p).influence.level, 2)

    def test_cant_create_order_twice(self):
        """
		Order can't be created twice
		"""
        o2 = BuyInfluenceOrder(player=self.p)

        self.assertRaises(OrderNotAvailable, o2.clean)
Esempio n. 4
0
    def setUp(self):
        super(InformationRunOrderTest, self).setUp()

        self.p2 = Player(game=self.g, secrets="Some nasty sfuff")
        self.p2.save()
        self.p2.citizenship.corporation = self.c
        self.p2.citizenship.save()

        from engine_modules.influence.models import BuyInfluenceOrder

        # Initial setup, create a resolution sheet we'll use later.
        o = BuyInfluenceOrder(player=self.p2)
        o.save()

        self.g.resolve_current_turn()

        self.io = InformationOrder(
            target=self.p2,
            player=self.p,
            additional_percents=0,
        )
        self.io.clean()
        self.io.save()

        self.set_to_zero(self.io.target.citizenship.corporation)
Esempio n. 5
0
class TasksTest(EngineTestCase):
    def setUp(self):
        super(TasksTest, self).setUp()
        self.o = BuyInfluenceOrder(player=self.p)
        self.o.save()

    def test_task_applied(self):
        """
		The new player should have influence of 1 after turn resolution
		"""
        self.g.resolve_current_turn()
        self.assertEqual(self.reload(self.p).influence.level, 2)
Esempio n. 6
0
    def test_orders_page(self):
        """
		Check orders page display current orders
		"""
        from engine_modules.influence.models import BuyInfluenceOrder
        o = BuyInfluenceOrder(player=self.p)
        o.save()

        # Order is displayed
        page = reverse('website.views.orders.orders', args=[self.g.id])
        r = self.authenticated_client.post(page)
        self.assertIn(o, r.context['existing_orders'])
Esempio n. 7
0
    def test_orders_page(self):
        """
		Check orders page display current orders
		"""
        from engine_modules.influence.models import BuyInfluenceOrder

        o = BuyInfluenceOrder(player=self.p)
        o.save()

        # Order is displayed
        page = reverse("website.views.orders.orders", args=[self.g.id])
        r = self.authenticated_client.post(page)
        self.assertIn(o, r.context["existing_orders"])
Esempio n. 8
0
class TasksTest(EngineTestCase):
	def setUp(self):
		super(TasksTest, self).setUp()
		self.o = BuyInfluenceOrder(
			player=self.p
		)
		self.o.save()

	def test_task_applied(self):
		"""
		The new player should have influence of 2 after turn resolution
		"""
		self.g.resolve_current_turn()
		self.assertEqual(self.reload(self.p).influence.level, 2)
Esempio n. 9
0
    def test_pages_redirect(self):
        """
		Check pages redirect after use
		"""
        from engine_modules.influence.models import BuyInfluenceOrder

        o = BuyInfluenceOrder(player=self.p)
        o.save()

        pages = [reverse("website.views.orders.delete_order", args=[self.g.id, o.pk])]

        for page in pages:
            r = self.authenticated_client.get(page)
            self.assertEqual(r.status_code, 302)
Esempio n. 10
0
    def test_pages_redirect(self):
        """
		Check pages redirect after use
		"""
        from engine_modules.influence.models import BuyInfluenceOrder
        o = BuyInfluenceOrder(player=self.p)
        o.save()

        pages = [
            reverse('website.views.orders.delete_order',
                    args=[self.g.id, o.pk]),
        ]

        for page in pages:
            r = self.authenticated_client.get(page)
            self.assertEqual(r.status_code, 302)
Esempio n. 11
0
    def test_task_applied_once(self):
        """
		Check a task is only applied once, and not every turn
		"""
        from engine_modules.influence.models import BuyInfluenceOrder

        o = BuyInfluenceOrder(player=self.p)
        o.save()

        start_influence = self.p.influence.level
        self.g.resolve_current_turn()
        self.assertEqual(
            self.reload(self.p).influence.level, start_influence + 1)

        # Check order is only applied on creation turn, not every turn
        self.g.resolve_current_turn()
        self.assertEqual(
            self.reload(self.p).influence.level, start_influence + 1)
Esempio n. 12
0
	def test_task_applied_once(self):
		"""
		Check a task is only applied once, and not every turn
		"""
		from engine_modules.influence.models import BuyInfluenceOrder

		o = BuyInfluenceOrder(
			player=self.p
		)
		o.save()

		start_influence = self.p.influence.level
		self.g.resolve_current_turn()
		self.assertEqual(self.reload(self.p).influence.level, start_influence + 1)

		# Check order is only applied on creation turn, not every turn
		self.g.resolve_current_turn()
		self.assertEqual(self.reload(self.p).influence.level, start_influence + 1)