コード例 #1
0
ファイル: test_forms.py プロジェクト: fancysauced/Ghostwriter
 def setUpTestData(cls):
     cls.unavailable_status = ServerStatusFactory(
         server_status="Unavailable")
     cls.server = StaticServerFactory()
     cls.unavailable_server = StaticServerFactory(
         server_status=cls.unavailable_status)
     cls.project = ProjectFactory()
コード例 #2
0
    def test_prop_count_status(self):
        status = ServerStatusFactory(server_status="Enabled")
        StaticServerFactory(server_status=status)

        try:
            count = status.count
            self.assertEqual(count, 1)
        except Exception:
            self.fail(
                "ServerStatus model `count` property failed unexpectedly!")
コード例 #3
0
    def test_crud(self):
        # Create
        status = ServerStatusFactory(server_status="Available")

        # Read
        self.assertEqual(status.server_status, "Available")
        self.assertEqual(status.pk, status.id)
        self.assertQuerysetEqual(
            self.ServerStatus.objects.all(),
            [f"<ServerStatus: {status}>"],
        )

        # Update
        status.server_status = "Unavailable"
        status.save()
        self.assertEqual(status.server_status, "Unavailable")

        # Delete
        status.delete()
        assert not self.ServerStatus.objects.all().exists()
コード例 #4
0
 def setUpTestData(cls):
     cls.ServerHistory = ServerHistoryFactory._meta.model
     cls.available_status = ServerStatusFactory(server_status="Available")
     cls.unavailable_status = ServerStatusFactory(
         server_status="Unavailable")