def test_init(self): # Test w/o Prefix or Key of = backend.PrefixedFactory(backend.TypedObject) obj = of.from_new() self.assertTrue(obj) self.assertEquals(obj.full_key, "{:s}".format(of.cls.__name__).lower()) # Test w/ Prefix but w/o Key pre = "testprefix" of = backend.PrefixedFactory(backend.TypedObject, prefix=pre) obj = of.from_new() self.assertTrue(obj) self.assertEquals(obj.full_key, "{:s}:{:s}".format(pre, of.cls.__name__).lower()) # Test w/ Key but w/o Prefix key = "testkey" of = backend.PrefixedFactory(backend.TypedObject) obj = of.from_new(key=key) self.assertTrue(obj) self.assertEquals(obj.full_key, "{:s}+{:s}".format(of.cls.__name__, key).lower()) # Test w/ Prefix and Key pre = "testprefix" kwy = "testkey" of = backend.PrefixedFactory(backend.TypedObject, prefix=pre) obj = of.from_new(key=key) self.assertTrue(obj) self.assertEquals(obj.full_key, "{:s}:{:s}+{:s}".format(pre, of.cls.__name__, key).lower())
def __init__(self, *args, **kwargs): """Submission Constructor""" # Call Parent Construtor super(Submission, self).__init__(*args, **kwargs) # Setup Factories self.AssignmentFactory = backend.UUIDFactory(Assignment) self.RunFactory = backend.UUIDFactory(Run) self.FileFactory = FileUUIDFactory() # Setup Lists FileListFactory = backend.PrefixedFactory(FileList, prefix=self.full_key) self.files = FileListFactory.from_raw(key='files') RunListFactory = backend.PrefixedFactory(RunList, prefix=self.full_key) self.runs = RunListFactory.from_raw(key='runs')
def __init__(self, *args, **kwargs): """Assignment Constructor""" # Call Parent Construtor super(Assignment, self).__init__(*args, **kwargs) # Setup Factories self.SubmissionFactory = backend.UUIDFactory(Submission) self.TestFactory = backend.UUIDFactory(Test) # Setup Lists TestListFactory = backend.PrefixedFactory(TestList, prefix=self.full_key) self.tests = TestListFactory.from_raw(key='tests') SubmissionListFactory = backend.PrefixedFactory(SubmissionList, prefix=self.full_key) self.submissions = SubmissionListFactory.from_raw(key='submissions')
def __init__(self, *args, **kwargs): """Base Constructor""" # Call Parent Construtor super(Group, self).__init__(*args, **kwargs) # Setup Lists UserListFactory = backend.PrefixedFactory(UserList, prefix=self.full_key) self.members = UserListFactory.from_raw(key='members')
def __init__(self, *args, **kwargs): """Test Constructor""" # Call Parent Construtor super(Test, self).__init__(**kwargs) # Setup Factories self.AssignmentFactory = backend.UUIDFactory(Assignment) self.FileFactory = FileUUIDFactory() self.ReporterFactory = backend.UUIDFactory(Reporter) # Setup Lists FileListFactory = backend.PrefixedFactory(FileList, prefix=self.full_key) self.files = FileListFactory.from_raw(key='files') ReporterListFactory = backend.PrefixedFactory(ReporterList, prefix=self.full_key) self.reporters = ReporterListFactory.from_raw(key='reporters')
def setUp(self): super(RedisObjectTestCase, self).setUp() self.key = 'key' self.cls_name = backend.TypedObject.__name__.lower() self.rid = "{:s}+{:s}".format(self.cls_name, self.key).lower() self.val = 'val' self.db.set(self.rid, self.val) self.ObjFactory = backend.PrefixedFactory(backend.TypedObject)
def __init__(self, prefix=None): # Call Parent super(Auth, self).__init__() # Save vars self.prefix = prefix # Setup Factories passthrough = {'auth': self} self.UserFactory = backend.UUIDFactory(User, prefix=self.prefix, passthrough=passthrough) self.GroupFactory = backend.UUIDFactory(Group, prefix=self.prefix, passthrough=passthrough) self.AllowedGroupsFactory = backend.PrefixedFactory(AllowedGroups, prefix=self.prefix, passthrough=passthrough) # Setup Lists UsernameMapFactory = backend.PrefixedFactory(UsernameMap, prefix=self.prefix, passthrough=passthrough) self.username_map = UsernameMapFactory.from_raw() TokenMapFactory = backend.PrefixedFactory(TokenMap, prefix=self.prefix, passthrough=passthrough) self.token_map = TokenMapFactory.from_raw()
def setUp(self): super(RedisSetTestCase, self).setUp() self.SetFactory = backend.PrefixedFactory(backend.Set)
def setUp(self): super(RedisTSHashTestCase, self).setUp() self.TSHashFactory = backend.PrefixedFactory(backend.TSHash)
def test_list(self): val = 'val' pre = 'test' cls = backend.TypedObject.__name__.lower() # Add Parents w/o Prefix self.db.flushdb() parents = ['p01', 'p02', 'p03'] for p in parents: self.db.set("{:s}+{:s}".format(cls, p).lower(), val) # Test Parents w/o Prefix hf = backend.PrefixedFactory(backend.TypedObject) fam = hf.list_family() self.assertEqual(set(parents), fam) sib = hf.list_siblings() self.assertEqual(set(parents), sib) chd = hf.list_children() self.assertFalse(chd) # Add Parents w/ Prefix self.db.flushdb() parents = ['p01', 'p02', 'p03'] for p in parents: self.db.set("{:s}:{:s}+{:s}".format(pre, cls, p), val) # Test Parents w/ Prefix hf = backend.PrefixedFactory(backend.TypedObject, prefix=pre) fam = hf.list_family() self.assertEqual(set(parents), fam) sib = hf.list_siblings() self.assertEqual(set(parents), sib) chd = hf.list_children() self.assertEqual(set([]), chd) # Add Parents + Children w/o Prefix self.db.flushdb() parents = ['p01', 'p02', 'p03'] for p in parents: self.db.set("{:s}+{:s}".format(cls, p), val) p1_children = ['c01', 'c02', 'c03'] full_children = [] for c in p1_children: child = "{:s}:{:s}+{:s}".format(parents[0], cls, c) self.db.set("{:s}+{:s}".format(cls, child), val) full_children.append(child) # Test Parents + Children w/o Prefix hf = backend.PrefixedFactory(backend.TypedObject) fam = hf.list_family() self.assertEqual(set(parents + full_children), fam) sib = hf.list_siblings() self.assertEqual(set(parents), sib) chd = hf.list_children() self.assertEqual(set(full_children), chd) # Test Children w/o Prefix chd_pre = "{:s}+{:s}".format(cls, parents[0]) hf = backend.PrefixedFactory(backend.TypedObject, prefix=chd_pre) fam = hf.list_family() self.assertEqual(set(p1_children), fam) sib = hf.list_siblings() self.assertEqual(set(p1_children), sib) chd = hf.list_children() self.assertEqual(set([]), chd) # Add Parents + Children w/ Prefix self.db.flushdb() parents = ['p01', 'p02', 'p03'] for p in parents: self.db.set("{:s}:{:s}+{:s}".format(pre, cls, p), val) p1_children = ['c01', 'c02', 'c03'] full_children = [] for c in p1_children: child = "{:s}:{:s}+{:s}".format(parents[0], cls, c) self.db.set("{:s}:{:s}+{:s}".format(pre, cls, child), val) full_children.append(child) # Test Parents + Children w/ Prefix hf = backend.PrefixedFactory(backend.TypedObject, prefix=pre) fam = hf.list_family() self.assertEqual(set(parents + full_children), fam) sib = hf.list_siblings() self.assertEqual(set(parents), sib) chd = hf.list_children() self.assertEqual(set(full_children), chd) # Test Children w/ Prefix chd_pre = "{:s}:{:s}+{:s}".format(pre, cls, parents[0]) hf = backend.PrefixedFactory(backend.TypedObject, prefix=chd_pre) fam = hf.list_family() self.assertEqual(set(p1_children), fam) sib = hf.list_siblings() self.assertEqual(set(p1_children), sib) chd = hf.list_children() self.assertEqual(set([]), chd)