File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+ # Copyright 2017-TODAY LasLabs Inc.
3+ # License MIT (https://opensource.org/licenses/MIT).
4+
5+ from carepoint import Carepoint
6+ from sqlalchemy import (Column ,
7+ DateTime ,
8+ ForeignKey ,
9+ Integer ,
10+ String ,
11+ Numeric ,
12+ )
13+
14+
15+ class ImageData (Carepoint .BASE ):
16+ __tablename__ = 'cpimage_data'
17+ __dbname__ = 'cph'
18+
19+ image_id = Column (
20+ Integer ,
21+ # Column is not actually a primary key in DB.
22+ primary_key = True ,
23+ )
24+ image_type_cn = Column (
25+ Integer ,
26+ )
27+ related_id = Column (
28+ Integer ,
29+ # Column is not actually a primary key in DB.
30+ primary_key = True ,
31+ )
32+ RootFolderName = Column (
33+ String ,
34+ )
35+ FullFileName = Column (
36+ String ,
37+ )
38+ related_store_id = Column (
39+ Integer ,
40+ ForeignKey ('csstore.store_id' ),
41+ )
42+ related_pat_id = Column (
43+ Integer ,
44+ ForeignKey ('cppat.pat_id' ),
45+ )
46+ add_user_id = Column (
47+ Integer ,
48+ ForeignKey ('csuser.user_id' ),
49+ )
50+ add_date = Column (DateTime )
51+ chg_user_id = Column (
52+ Integer ,
53+ ForeignKey ('csuser.user_id' ),
54+ )
55+ chg_date = Column (DateTime )
56+ image_path = property (lambda s : s ._compute_image_path ())
57+
58+ def _compute_image_path (self ):
59+ return '%s/%s' % (self .RootFolderName , self .FullFileName )
Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+ # Copyright 2015-TODAY LasLabs Inc.
3+ # License MIT (https://opensource.org/licenses/MIT).
4+
5+ import unittest
6+ from sqlalchemy .schema import Table
7+ from carepoint .tests .db .db import DatabaseTest
8+ from carepoint .models .cph .image_data import ImageData
9+
10+
11+ class TestImageData (DatabaseTest ):
12+
13+ def test_table_initialization (self ):
14+ self .assertIsInstance (ImageData .__table__ , Table )
15+
16+ def test_compute_image_path (self ):
17+ image = ImageData (
18+ RootFolderName = 'root' ,
19+ FullFileName = 'file' ,
20+ )
21+ self .assertEqual (image .image_path , 'root/file' )
22+
23+
24+ if __name__ == '__main__' :
25+ unittest .main ()
You can’t perform that action at this time.
0 commit comments