Example #1
0
 def test_repr_getter_setter(self):
     from core.TestType import TestType
     my_type = str(uuid.uuid4())
     doc = [str(uuid.uuid4()), str(uuid.uuid4()), str(uuid.uuid4())]
     doc_fields_to_index = [doc[0]]
     test_type = TestType(my_type, doc, doc_fields_to_index)
     assert '{0}'.format(test_type) == '<TestType {0} ({1})>'.format(my_type, doc)
     assert test_type.to_dict() == {'type': my_type, 'doc_fields': doc, 'doc_fields_to_index': [doc[0]]}
     test_type2 = TestType.from_dict(test_type.to_dict())
     assert test_type2.to_dict() == test_type.to_dict()
Example #2
0
 def test_purge(self):
     from core.TestType import TestType
     from core.Base import Base
     from core.Filter import Filter
     my_type1 = str(uuid.uuid4())
     doc1 = [str(uuid.uuid4()), str(uuid.uuid4()), str(uuid.uuid4())]
     test_type = TestType(my_type1, doc1)
     assert test_type.purge() == test_type._default_purge
     assert test_type.set_purge('REMOVE', {'operator': str(uuid.uuid4()), 'field': 1, 'value': 1}) == False
     condition = {'operator': 'EQUAL', 'field': 1, 'value': 1}
     action = str(uuid.uuid4())
     res = test_type.set_purge(action, condition)
     assert res == False
     assert test_type.purge() == test_type._default_purge
     action = 'REMOVE'
     res = test_type.set_purge(action, condition)
     assert res
     assert test_type.to_dict()['purge']['action'] == action
     assert test_type.to_dict()['purge']['condition'] == condition
     test_type2 = TestType.from_dict(test_type.to_dict())
     assert test_type.purge()['action'] == 'REMOVE'
     assert test_type.purge()['condition'].to_dict() == condition
     assert test_type2.purge()['action'] == 'REMOVE'
     assert test_type2.purge()['condition'].to_dict() == condition