################################################################################
-class Priority(object):
- def __init__(self, *args, **kwargs):
- pass
+class Priority(ORMObject):
+ def __init__(self, priority = None, level = None):
+ self.priority = priority
+ self.level = level
+
+ def properties(self):
+ return ['priority', 'priority_id', 'level', 'overrides_count']
+
+ def not_null_constraints(self):
+ return ['priority', 'level']
def __eq__(self, val):
if isinstance(val, str):
# This signals to use the normal comparison operator
return NotImplemented
- def __repr__(self):
- return '<Priority %s (%s)>' % (self.priority, self.priority_id)
-
__all__.append('Priority')
@session_wrapper
component_id = self.tbl_override.c.component,
component = relation(Component),
priority_id = self.tbl_override.c.priority,
- priority = relation(Priority),
+ priority = relation(Priority, \
+ backref=backref('overrides', lazy='dynamic')),
section_id = self.tbl_override.c.section,
section = relation(Section, \
backref=backref('overrides', lazy='dynamic')),
from db_test import DBDakTestCase
from daklib.dbconn import DBConn, BinContents, OverrideType, get_override_type, \
- Section, get_section, get_sections
+ Section, get_section, get_sections, Priority, get_priority, get_priorities
from sqlalchemy.exc import FlushError, IntegrityError
import unittest
self.assertEqual(section.section_id, all_sections['python'])
self.assertEqual(0, section.overrides.count())
+ def test_priority(self):
+ '''
+ Test Priority class.
+ '''
+ priority = Priority(priority = 'standard', level = 7)
+ self.session.add(priority)
+ self.session.flush()
+ self.assertEqual('standard', priority.priority)
+ self.assertEqual(7, priority.level)
+ self.assertEqual('standard', priority)
+ self.assertTrue(priority != 'extra')
+ self.assertEqual(priority, get_priority('standard', self.session))
+ all_priorities = get_priorities(self.session)
+ self.assertEqual(priority.priority_id, all_priorities['standard'])
+ self.assertEqual(0, priority.overrides.count())
+
if __name__ == '__main__':
unittest.main()