コード例 #1
0
class TagServiceTest(DatabaseTest):
    def setUp(self):
        DatabaseTest.setUp(self)
        self.tag_service = TagService()

    def test_get_all_tags(self):
        tag1 = TagStore(name="tag-1")
        tag2 = TagStore(name="tag-2")
        self.session.add(tag1)
        self.session.add(tag2)
        self.session.commit()
        tags = self.tag_service.get_all_tags(self.session)
        assert_true(len(tags), 2)
        assert_true(tags[0], "tag-1")
        assert_true(tags[1], "tag-2")

    def test_get_all_tags_empty(self):
        self.tag_service = TagService()
        tags = self.tag_service.get_all_tags(self.session)
        assert_equal(tags, [])
コード例 #2
0
def setup_cohort_service():
    if request.endpoint is not None:
        if request.path.startswith('/cohorts'):
            cohort_service = getattr(g, 'cohort_service', None)
            tag_service = getattr(g, 'tag_service', None)
            centralauth_service = getattr(g, 'centralauth_service', None)
            if cohort_service is None:
                g.cohort_service = CohortService()
            if tag_service is None:
                g.tag_service = TagService()
            if centralauth_service is None:
                g.centralauth_service = CentralAuthService()
コード例 #3
0
 def setUp(self):
     DatabaseTest.setUp(self)
     self.tag_service = TagService()
コード例 #4
0
 def test_get_all_tags_empty(self):
     self.tag_service = TagService()
     tags = self.tag_service.get_all_tags(self.session)
     assert_equal(tags, [])