コード例 #1
0
ファイル: test_runway.py プロジェクト: zwcdp/fashion
 def test_create(self, tmp_path):
     dba = DatabaseAccess(tmp_path / "db.json")
     fw = Warehouse(FASHION_WAREHOUSE_PATH)
     wh = Warehouse(tmp_path, fw)
     wh.loadSegments(dba)
     r = Runway(dba, wh)
     assert r is not None
コード例 #2
0
ファイル: test_runway.py プロジェクト: zwcdp/fashion
 def test_loadSchemas(self, tmp_path):
     dba = DatabaseAccess(tmp_path / "db.json")
     fw = Warehouse(FASHION_WAREHOUSE_PATH)
     wh = Warehouse(tmp_path, fw)
     wh.loadSegments(dba)
     r = Runway(dba, wh)
     r.loadSchemas()
コード例 #3
0
ファイル: test_warehouse.py プロジェクト: zwcdp/fashion
 def test_warehouseFallback(self, tmp_path):
     '''Test the local warehouse refers properly to another warehouse.'''
     dba = DatabaseAccess(tmp_path / "db.json")
     fw = Warehouse(FASHION_WAREHOUSE_PATH)
     lw = Warehouse(tmp_path, fw)
     coreSeg = lw.loadSegment("fashion.core", dba)
     assert coreSeg is not None
コード例 #4
0
 def test_contextReset(self, tmp_path):
     '''
     Test that when a context is re-entered, the previous context data is
     reset.
     '''
     dba = DatabaseAccess(tmp_path / "db.json")
     d = DummyContextOut()
     schemaRepo = SchemaRepository()
     with ModelAccess(dba, schemaRepo, d) as mdb:
         id = mdb.insert("dummy.output", {"name": "dummy model"})
         assert id is not None
     ctxs = dba.table('fashion.prime.context').all()
     assert len(ctxs) == 1
     models = dba.table('dummy.output').all()
     assert len(models) == 1
     # Now re-enter the same context
     with ModelAccess(dba, schemaRepo, d) as mdb:
         ctxs = dba.table('fashion.prime.context').all()
         assert len(ctxs) == 0
         models = dba.table('dummy.output').all()
         assert len(models) == 0
         id = mdb.insert("dummy.output", {"name": "dummy model the second"})
         assert id is not None
     ctxs = dba.table('fashion.prime.context').all()
     assert len(ctxs) == 1
     models = dba.table('dummy.output').all()
     assert len(models) == 1
     assert models[0]["name"] == "dummy model the second"
     dba.close()
コード例 #5
0
ファイル: test_warehouse.py プロジェクト: zwcdp/fashion
 def test_loadSegments(self, tmp_path):
     '''Test loading all segments in a warehouse.'''
     dba = DatabaseAccess(tmp_path / "db.json")
     wh = Warehouse(tmp_path)
     newSegName = "custom"
     wh.newSegment(newSegName, dba)
     segs = wh.loadSegments(dba)
     assert len(segs) == 1
     assert segs[0].properties.name == newSegName
コード例 #6
0
ファイル: portfolio.py プロジェクト: zwcdp/fashion
 def create(self):
     '''Create a new portfolio.'''
     if not self.exists():
         self.segments = {}
         self.__setDefaultProperties()
         self.fashionPath.mkdir(parents=True, exist_ok=True)
         (self.fashionPath / "warehouse").mkdir(parents=True, exist_ok=True)
         self.db = DatabaseAccess(self.fashionDbPath)
         self.loadWarehouses()
         self.warehouse.newSegment("local", self.db)
         self.save()
コード例 #7
0
ファイル: test_warehouse.py プロジェクト: zwcdp/fashion
 def test_newSegment(self, tmp_path):
     '''Test creating a new segment in a warehouse.'''
     dba = DatabaseAccess(tmp_path / "db.json")
     newSegName = "custom"
     wh = Warehouse(tmp_path)
     wh.newSegment(newSegName, dba)
     segNames = wh.listSegments()
     assert len(segNames) == 1
     assert segNames[0] == newSegName
     seg = wh.loadSegment(segNames[0], dba)
     assert seg is not None
コード例 #8
0
 def test_create(self, tmp_path):
     dba = DatabaseAccess(tmp_path / "db.json")
     d = DummyContextOut()
     schemaRepo = SchemaRepository()
     with ModelAccess(dba, schemaRepo, d) as mdb:
         id = mdb.insert("dummy.output", {"name": "dummy model"})
         assert id is not None
     ctxs = dba.table('fashion.prime.context').all()
     assert len(ctxs) == 1
     assert len(ctxs[0]["insert"]) == 1
     assert 'dummy.output' in ctxs[0]["insert"]
     assert id in ctxs[0]["insert"]['dummy.output']
     models = dba.table('dummy.output').all()
     assert len(models) == 1
     dba.close()
コード例 #9
0
ファイル: portfolio.py プロジェクト: zwcdp/fashion
    def __init__(self, projDir):
        '''
        Initialize a portfolio mapped to the given directory, whether or not 
        the directory actually exists.

        :param str projDir: where the project is located. 
        '''
        self.projectPath = projDir.absolute()
        self.fashionPath = self.projectPath / 'fashion'
        self.mirrorPath = self.fashionPath / 'mirror'
        self.portfolioPath = self.fashionPath / 'portfolio.json'
        self.fashionDbPath = self.fashionPath / 'database.json'
        self.mirror = Mirror(self.projectPath, self.mirrorPath)
        if self.fashionDbPath.exists():
            self.load()
            self.db = DatabaseAccess(self.fashionDbPath)
コード例 #10
0
ファイル: test_runway.py プロジェクト: zwcdp/fashion
 def test_loadModules(self, tmp_path):
     dba = DatabaseAccess(tmp_path / "db.json")
     fw = Warehouse(FASHION_WAREHOUSE_PATH)
     wh = Warehouse(tmp_path, fw)
     wh.loadSegments(dba)
     r = Runway(dba, wh)
     dba.setSingleton('fashion.prime.args',
         {
             "force":False,
             "verbose":True
         })
     mirrorDir = tmp_path / "mirror"
     mirrorDir.mkdir()
     dba.setSingleton('fashion.prime.portfolio',
         {
             "projectPath":".",
             "mirrorPath":mirrorDir.as_posix()
         })
     r.loadModules()
     r.initModules()
     r.plan()
     r.execute()
コード例 #11
0
 def test_reading(self, tmp_path):
     '''Test searching for models.'''
     dba = DatabaseAccess(tmp_path / "db.json")
     dOut = DummyContextOut()
     schemaRepo = SchemaRepository()
     with ModelAccess(dba, schemaRepo, dOut) as mdb:
         id = mdb.insert("dummy.output", {"name": "dummy model"})
     dIn = DummyContextIn()
     with ModelAccess(dba, schemaRepo, dIn) as mdb:
         m = mdb.getById("dummy.output", id)
         assert m is not None
         assert m["name"] == "dummy model"
         m = mdb.getByKind("dummy.output")
         assert m is not None
         assert len(m) == 1
         assert m[0]["name"] == "dummy model"
         dummyQ = Query()
         m = mdb.search("dummy.output", dummyQ.name == "dummy model")
         assert m is not None
         assert len(m) == 1
         assert m[0]["name"] == "dummy model"
     dba.close()
コード例 #12
0
ファイル: test_databaseAccess.py プロジェクト: zwcdp/fashion
 def test_init(self, tmp_path):
     fashionDbPath = tmp_path / 'fashion_database.json'
     db = DatabaseAccess(fashionDbPath)
     assert db is not None