Skip to content

Commit

Permalink
add new test script for columnProxy and related objects, to be completed
Browse files Browse the repository at this point in the history
  • Loading branch information
icyveins7 committed Mar 15, 2024
1 parent b7ee6ad commit eea7266
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
7 changes: 7 additions & 0 deletions sew/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,13 @@ def formatSpecifier(self):
'''
return self._fmt

@property
def cols(self):
'''
Alias for .columns.
'''
return self._cols

@property
def columns(self):
'''
Expand Down
12 changes: 12 additions & 0 deletions sew/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ def __ne__(self, x):
self._requireType(x)
return "%s != %s" % (self._name, str(x))

#%%
class ColumnProxyContainer:
"""
Container of ColumnProxy objects, useful to access each ColumnProxy by name
as an attribute.
This makes the code easier to type as opposed to a dictionary; e.g.
mytable.cols.mycolname
"""
def __init__(self, columnProxies: list[ColumnProxy]):
for col in columnProxies:
setattr(self, col.name, col)



6 changes: 5 additions & 1 deletion tests/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

# Import statements unittests
print("Running statements unittests")
from.statements import *
from .statements import *

# Import columns unittests
print("Running columns unittests")
from .columns import *

# Import correctness unittests
print("Running correctness unittests")
Expand Down
2 changes: 1 addition & 1 deletion tests/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

import sew
import sew.plugins
import sew.blobInterpreter
import sew.blobInterpreter
14 changes: 14 additions & 0 deletions tests/columns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Load all imports using helper
from ._helpers import *

import unittest

#%%
class TestColumnProxy(unittest.TestCase):
def test_columnProxy_properties(self):
# Create a simple one
proxy = sew.ColumnProxy("col1", "int", "mytbl")
self.assertEqual(proxy.name, "col1")
self.assertEqual(proxy.typehint, "int")
self.assertEqual(proxy.tablename, "mytbl")

0 comments on commit eea7266

Please sign in to comment.