Esempio n. 1
0
    def test_person_fields(self):
        
        with self.app.test_client() as client:
            with self.app.test_request_context():

                DB.create_all()

                person = models.Person.create(
                    name = 'John Doe',
                    username = '******',
                    email = '*****@*****.**',
                    website = 'http://johnd.com',
                    password = '******',
                )
                
                DB.session.add(person)
                DB.session.commit()

                self.assertEqual(
                    dict(marshal(person, person_fields)),
                    {"id": 1, "username": u"johnd", "email":
                        u"*****@*****.**", "website":
                        u"http://johnd.com", 'name': u'John Doe',
                        "gravatar_email": None, "gravatar_id": None,
                        "avatar_url": None})
Esempio n. 2
0
    def test_officership_fields(self):
        
        with self.app.test_client() as client:
            with self.app.test_request_context():

                DB.create_all()

                person = models.Person.create(
                    name = 'John Doe',
                    username = '******',
                    email = '*****@*****.**',
                    website = 'http://johnd.com',
                    password = '******',
                )

                DB.session.add(person)

                officership = models.Officership.create(
                    person = person,
                    title = 'Vice Chair',        
                    start_date = datetime.date(2014, 4, 15),
                    end_date = datetime.date(2014, 4, 16))

                DB.session.add(officership)

                DB.session.commit()

                self.assertEqual(
                    dict(marshal(officership, officership_fields)),
                    {'id': 1, 'title': u'Vice Chair', 'person_id': 1,
                    'person': 'http://localhost/people/1',
                    'start_date': '2014-04-15',
                    'end_date': '2014-04-16'})
Esempio n. 3
0
    def setUp(self):
        self.app = Flask(__name__)

        self.app.testing = True
        
        self.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
        
        DB.init_app(self.app)
        
        API.init_app(self.app)
Esempio n. 4
0
    def test_event_fields(self):
        
        with self.app.test_client() as client:
            with self.app.test_request_context():

                DB.create_all()
                 
                person = models.Person.create(
                    name = 'John Doe',
                    username = '******',
                    email = '*****@*****.**',
                    website = 'http://johnd.com',
                    password = '******',
                )

                event = models.Event.create(
                    title = "Event 1",
                    description = "This is Event 1",
                    speaker = "By the Event 1 speaker",
                    location = "In the Event Room",
                    editor = person,
                    edited_datetime = 
                        datetime.datetime(2014, 4, 15, 21, 20, 30),
                    start =
                        datetime.datetime(2014, 4, 15, 21, 20, 30),
                    end =
                        datetime.datetime(2014, 4, 16, 21, 20, 30),
                    canceled = False,
                    hidden = False,
                    list = 0,
                    index = 0,
                )

                DB.session.add(person)

                DB.session.add(event)

                DB.session.commit()
                DB.create_all()

                self.assertEqual(
                    dict(marshal(event, event_fields)),
                    {'event_id': 0, 'description': u'This is Event 1',
                    'location': u'In the Event Room', 
                    'speaker': u'By the Event 1 speaker',
                    'title': u'Event 1', 'canceled': False,
                    'hidden': False, 
                    'start': '2014-04-15 21:20:30.000000',
                    'end': '2014-04-16 21:20:30.000000',
                    'revision': 0, 
                    'edited_at': '2014-04-15 21:20:30.000000',
                    'editor_id': 1,
                    'editor': 'http://localhost/people/1'})
Esempio n. 5
0
    def test_post_fields(self):
        
        with self.app.test_client() as client:
            with self.app.test_request_context():

                DB.create_all()

                person = models.Person.create(
                    name = 'John Doe',
                    username = '******',
                    email = '*****@*****.**',
                    website = 'http://johnd.com',
                    password = '******',
                )

                DB.session.add(person)
                 
                post = models.Post.create(
                    title = 'Post 1',
                    description = 'This is Post 1',
                    content = 'This is Post 1 content',
                    editor = person,
                    edited_datetime = 
                        datetime.datetime(2014, 4, 15, 21, 20, 30),
                    hidden = False,
                    list = 0,
                    index = 0,
                 )

                DB.session.add(post)
         
                DB.session.commit()

                self.assertEqual(
                    dict(marshal(post, post_fields)),
                    {'post_id': 0, 'description': u'This is Post 1',
                    'content': 'This is Post 1 content',
                    'title': u'Post 1', 'hidden': False, 
                    'revision': 0, 
                    'edited_at': '2014-04-15 21:20:30.000000',
                    'editor_id': 1,
                    'editor': 'http://localhost/people/1'})