Ejemplo n.º 1
0
    def setUp(self):
        
        class PersistenceMock3:
            def __init__(self):
                self.savedmodel = [Thing("fred"), Thing("sam")]
                
            def SetApp(self, app):
                self.app = app
                
            def SaveAll(self, model):
                self.savedmodel = model
            
            def LoadAll(self):
                return self.savedmodel

        class GuiMock:
            def __init__(self):
                self._trace_notifycalls = 0
            def SetApp(self, app):
                self.app = app
            def NotifyOfModelChange(self, event, thing):
                self._trace_notifycalls += 1
                
        class ServerMock:
            def SetApp(self, app):
                self.app = app
                
        self.app = App(PersistenceMock3(), ServerMock(), GuiMock())
Ejemplo n.º 2
0
# BOOT WIRING

from hexappmodel import App, Thing
from hexpersistence import PersistenceMock, PersistenceMock2

#app = App(PersistenceMock())
app = App(PersistenceMock2())

# UNIT TEST

app.Load()
print app.model

thing1 = app.GetThing(0)
app.AddInfoToThing(thing1, "once")
print app.model

app.New()
app.CreateThing("once")
app.CreateThing("upon a time")
app.Save()
print app.model

app.New()
print app.model

app.Load()
print app.model
Ejemplo n.º 3
0
# HEXMVC BOOT WIRING v2 - assumes app and model in the same import module

from hexappmodel import App
from hexpersistence import PersistenceMock2
from hexserver import Server1
from hexmvcgui import MyWxApp
import wx

# Create Gui
wxapp = MyWxApp(redirect=False)
gui = wxapp.myframe  # arguably too wx based to be a true adapter, but as long
# as we call nothing wx specific, it acts as an adapter ok.
# Create Server
server = Server1(host="localhost", port=8081)

# Create Persistence
persistence = PersistenceMock2()

# Create Core Hexagon App and inject adapters
app = App(persistence, server, gui)
wx.CallAfter(app.Boot)

# Start Gui
wxapp.MainLoop()

print("DONE")