Ejemplo n.º 1
0
    def test_method_will_be_released(self):
        start_date = date.today() - timedelta(days=20)
        end_date = date.today() + timedelta(days=7)
        entry = ServerHistoryFactory(start_date=start_date, end_date=end_date)

        try:
            self.assertEqual(False, entry.will_be_released())

            entry.end_date = date.today()
            entry.save()
            self.assertEqual(True, entry.will_be_released())
        except Exception:
            self.fail(
                "ServerHistory model `will_be_released` method failed unexpectedly!"
            )
Ejemplo n.º 2
0
    def test_crud(self):
        # Create
        entry = ServerHistoryFactory(server=StaticServerFactory(
            name="teamserver.local"))

        # Read
        self.assertEqual(entry.server.name, "teamserver.local")
        self.assertEqual(entry.pk, entry.id)
        self.assertQuerysetEqual(
            self.ServerHistory.objects.all(),
            [
                f"<ServerHistory: {entry.server.ip_address} ({entry.server.name}) [{entry.activity_type}]>"
            ],
        )

        # Update
        entry.end_date = date.today()
        entry.save()
        self.assertEqual(entry.end_date, date.today())

        # Delete
        entry.delete()
        assert not self.ServerHistory.objects.all().exists()