Example #1
0
 def test_send_epistle_by_id(self):
     #@TODO: as this test illustrates, we should make a "send_epistle" function in queries
     u1 = users.create_user(username = '******', password='******')
     u2 = users.create_user(username = '******', password='******')
     ep = Epistle(u1.id, u2.id, u'test epistle', subject = u'a simple test')
     self.dbsession.add(ep)
     self.dbsession.flush()
     epd = queries.get_epistle_by_recipient_id(u1.id)[0]
     self.assertEqual(ep.id, epd.id)
Example #2
0
 def test_create_user(self, username = None):
     if not username:
         username = '******'
     u = users.create_user(username = username, password = username,)
     res = self.dbsession.query(User).filter(User.name == username).first()
     self.assertEqual(res.id, u.id)
     self.assertEqual(res.name, u.name)
Example #3
0
    def test_domain_parse(self):
        title = 'test'
        description = 'test'
        #@TODO: we should make this accept a fake user id in test mode at least
        # so that we don't have huge cascading failures if create_user is broken
        user = users.create_user(username='******', password='******')

        sub = Submission(title, description, 'http://google.com', user.id)
        self.assertEqual('google.com', sub.get_domain_name())

        sub = Submission(title, description, 'http://googlewww.com', user.id)
        self.assertEqual('googlewww.com', sub.get_domain_name())

        sub = Submission(title, description, 'https://google.com', user.id)
        self.assertEqual('google.com', sub.get_domain_name())
Example #4
0
    def test_create_submission(self):
        #@TODO: another function that should be split out of the view for easy repitition.
        # if the view code changes substantially, this test will not keep up
        user = users.create_user(username = '******', password = '******')
        url = 'http://google.com'
        title = 'test'
        description = 'test'

        if url != '' and url is not None:
            url = queries.strip_all_html(url)
            if not re.match(r'http[s]*:\/\/', url):
                url = 'http://' + url
        else:
            # set to None so that NULL goes into the database
            url = None

        sub = Submission(title, description, url, user.id)
        self.dbsession.add(sub)
        self.dbsession.flush()
        s = submission.get_story_by_id(sub.id)
        self.assertEqual(s.id, sub.id)
Example #5
0
 def test_find_by_id_user(self):
     # depends on functional test_create_user
     u = users.create_user(username = '******', password='******')
     res = queries.find_by_id(u.id)
     self.assertEqual(res.id, u.id)
     self.assertEqual(res.name, u.name)
Example #6
0
 def test_get_user_by_name(self):
     u = users.create_user(username = '******', password='******')
     res = users.get_user_by_name(u.name)
     self.assertEqual(u.id, res.id)