Exemplo n.º 1
0
    def test_search_by_title_provided(self):
        search_term = 'foo'
        clg = catalog.Catalog(search_term, True)
        clg.apply()

        self.assertEqual(len(clg.projects), 1)
        self.assertEqual(clg.projects[0].title, 'foo')
Exemplo n.º 2
0
    def test_apply_chooses_correct_table(self):
        project.Provided().post('foo', 'bar', self.user)
        project.Solicited().post('your', 'mom', self.user)
        clg = catalog.Catalog('', False)
        clg.apply()

        self.assertEqual(len(clg.projects), 1)
        self.assertEqual(clg.projects[0].title, 'your')
        self.assertEqual(clg.projects[0].description, 'mom')
Exemplo n.º 3
0
    def test_search_by_title_provided(self):
        project.Provided().post('foo', 'bar', User(id=1))
        project.Provided().post('hello', 'world', User(id=1))
        search_term = 'foo'
        clg = catalog.Catalog(search_term, True)
        clg.apply()

        self.assertEqual(len(clg.projects), 1)
        self.assertEqual(clg.projects[0].title, 'foo')
Exemplo n.º 4
0
    def setUp(self):
        self.session = self.Session()
        self.fake_project_list = [
            'these', "don't", 'need', 'to', 'be', 'real', 'projects'
        ]
        self.fake_catalog = catalog.Catalog()
        self.fake_catalog.projects = self.fake_project_list
        self.user = User(id=1, can_post_provided=True, can_post_solicited=True)

        project.Provided().post('foo', 'bar', self.user)
        project.Provided().post('nobody expects', 'the spanish inquisition',
                                self.user)
        project.Provided().post('sperm whale', 'bowl of petunias', self.user)
Exemplo n.º 5
0
    def test_append(self):
        p0 = self.session.query(project.Provided).filter_by(title='foo').one()
        p1 = self.session.query(
            project.Provided).filter_by(title='nobody expects').one()

        clg = catalog.Catalog('foo', True)
        clg.apply()
        clg.append(p1)
        self.assertEqual(len(clg), 2)
        self.assertEqual(clg[0].id, p0.id)
        self.assertEqual(clg[1].id, p1.id)

        with self.assertRaises(ValueError):
            clg.append(4)
Exemplo n.º 6
0
    def test_apply_many_projects(self):
        clg = catalog.Catalog('', True)
        clg.apply()

        self.assertEqual(len(clg.projects), 3)

        projects = []
        for proj in clg.projects:
            projects.append((proj.title, proj.description))

        self.assertTrue(('foo', 'bar') in projects)
        self.assertTrue(('nobody expects',
                         'the spanish inquisition') in projects)
        self.assertTrue(('sperm whale', 'bowl of petunias') in projects)
Exemplo n.º 7
0
    def test_extend(self):
        p0 = self.session.query(project.Provided).filter_by(title='foo').one()
        p1 = self.session.query(
            project.Provided).filter_by(title='nobody expects').one()
        p2 = self.session.query(
            project.Provided).filter_by(title='sperm whale').one()

        clg = catalog.Catalog('foo', True)
        clg.apply()
        clg.extend([p1, p2])
        self.assertEqual(len(clg), 3)
        self.assertEqual(clg[0].id, p0.id)
        self.assertEqual(clg[1].id, p1.id)
        self.assertEqual(clg[2].id, p2.id)

        with self.assertRaises(ValueError):
            clg.extend([p0, 4, p1])
    def test_get_user_projects(self):
        user.User.sign_up(**self.user_args)
        self.user = user.User.log_in('foo', 'barbarba')

        new_user = User(id=2, can_post_provided=True, can_post_solicited=True)
        project.Provided().post('Test', 'Fire', new_user)
        project.Provided().post('Interesting', 'Facts', new_user)
        project.Provided().post('Fall', 'Food', new_user)

        clg = catalog.Catalog('', True)
        clg.apply()

        projects = self.user.get_user_projects()

        self.assertEqual(len(clg.projects), 6)
        self.assertEqual(len(projects), 3)

        self.assertEqual('foo', projects[0].title)
        self.assertEqual('Awesome', projects[1].title)
        self.assertEqual('Cannon', projects[2].title)
Exemplo n.º 9
0
 def test_apply_no_projects(self):
     self.session.query(project.Provided).delete()
     clg = catalog.Catalog('', True)
     clg.apply()
     self.assertEqual(clg.projects, [])
Exemplo n.º 10
0
 def test_apply_no_projects(self):
     clg = catalog.Catalog('', True)
     clg.apply()
     self.assertEqual(clg.projects, [])