SampleSetList.py 1.54 KB
Newer Older
1 2 3 4
#!/usr/bin/python

import unittest

5
class SamplesetlistModel(unittest.TestCase):
6 7 8 9 10 11 12 13
        
    def __init__(self, p):
        global auth
        unittest.TestCase.__init__(self, p)
        
    def setUp(self):
        # Load the to-be-tested file
        execfile("applications/vidjil/models/sample_set_list.py", globals())
14 15
        global auth
        auth = VidjilAuth(globals(), db)
16
        auth.login_bare("test@vidjil.org", "123456")
17 18 19 20 21 22 23 24 25 26 27 28 29 30

    def testInit(self):
        slist = SampleSetList('patient')
        self.assertTrue(len(slist.element_ids) > 0, "The sample set list was not expected to be empty")

    def testCreatorNames(self):
        slist = SampleSetList('patient')
        slist.load_creator_names()
        values = slist.get_values() 
        first = values[0]
        name = first.creator
        self.assertFalse(name == "", "load_creator_names failed to retrieve a username")

    def testPermittedGroups(self):
31 32
        slist = SampleSetList('patient')
        slist.load_permitted_groups()
33 34 35 36
        value = slist.get_values()[0]
        groups = value.groups
        group_list = value.group_list

37 38
        self.assertFalse(groups == "", "load_permitted_groups didn't load ay groups")
        self.assertFalse(group_list == [], "load_permitted_groups found groups although the group_list is empty")
39 40

    def testAnonPermissions(self):
41 42
        slist = SampleSetList('patient')
        slist.load_anon_permissions()
43 44
        value = slist.get_values()[0]

45
        self.assertFalse(value.anon_allowed, "Anon was allowed, when it was not expected to be")
46 47