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()
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!")
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()
def setUpTestData(cls): cls.ServerHistory = ServerHistoryFactory._meta.model cls.available_status = ServerStatusFactory(server_status="Available") cls.unavailable_status = ServerStatusFactory( server_status="Unavailable")