Пример #1
0
    def setUp(self):
        self.db_fd, app.config['DATABASE'] = tempfile.mkstemp()
        app.config.update(
            TESTING=True,
            SQLALCHEMY_DATABASE_URI='sqlite:////%s' % app.config['DATABASE'],
            SECRET_KEY = os.urandom(24)
        )
        
        # create db and populate
        db.create_all()
        user = User(username='******')
        user.password = pwd_context.encrypt('doe')
        db.session.add(user)
        db.session.commit()

        # create product store
        now = dt.now().strftime('%a %b %d %H:%M:%S %Y')
        store.set('last-update', now)
        for i in range(5):
            pid = 's%d' % i
            store.lpush('user:%s:products' % user.id, pid)
            store.hset('products:%s' % pid, 'version', 1)

        # create a test app every test case can use.
        self.test_app = app.test_client()
Пример #2
0
    def setUp(self):
        self.db_fd, app.config['DATABASE'] = tempfile.mkstemp()
        app.config.update(TESTING=True,
                          SQLALCHEMY_DATABASE_URI='sqlite:////%s' %
                          app.config['DATABASE'],
                          SECRET_KEY=os.urandom(24))

        # create db and populate
        db.create_all()
        user = User(username='******')
        user.password = pwd_context.encrypt('doe')
        db.session.add(user)
        db.session.commit()

        # create product store
        now = dt.now().strftime('%a %b %d %H:%M:%S %Y')
        store.set('last-update', now)
        for i in range(5):
            pid = 's%d' % i
            store.lpush('user:%s:products' % user.id, pid)
            store.hset('products:%s' % pid, 'version', 1)

        # create a test app every test case can use.
        self.test_app = app.test_client()
Пример #3
0
 def test_sync_data_with_modifiedsince_header_ANSI_C_and_in_future(self):
     date = 'Sun Nov 6 08:49:37 2014'
     store.set('last-update', 'Sun Aug 6 08:49:37 2013')
     response = self.get_manifest_resource(modified=date)
     self.assertBadRequest(response)
Пример #4
0
 def test_sync_data_with_modifiedsince_header_ANSI_C_and_not_modified(self):
     date = 'Sun Nov 6 08:49:37 2014'
     store.set('last-update', date)
     response = self.get_manifest_resource(modified=date)
     self.assertNotModified(response)
Пример #5
0
 def test_sync_data_with_modifiedsince_header_RFC_1036_and_in_future(self):
     date = 'Sunday, 06-Nov-14 08:49:37 GMT'
     store.set('last-update', 'Sunday, 06-Nov-13 08:49:37 GMT')
     response = self.get_manifest_resource(modified=date)
     self.assertBadRequest(response)
Пример #6
0
 def test_sync_data_with_modifiedsince_header_RFC_1036_and_not_modified(self):
     date = 'Sunday, 06-Nov-14 08:49:37 GMT'
     store.set('last-update', date)
     response = self.get_manifest_resource(modified=date)
     self.assertNotModified(response)
Пример #7
0
 def test_sync_data_with_modifiedsince_header_RFC_1123_and_sync_needed(self):
     date = 'Sun, 06 Nov 2014 08:49:37 GMT'
     store.set('last-update', 'Sun, 06 Aug 2015 08:49:37 GMT')
     response = self.get_manifest_resource(modified=date)
     self.assertOk(response)
Пример #8
0
 def test_sync_data_with_modifiedsince_header_ANSI_C_and_in_future(self):
     date = 'Sun Nov 6 08:49:37 2014'
     store.set('last-update', 'Sun Aug 6 08:49:37 2013')
     response = self.get_manifest_resource(modified=date)
     self.assertBadRequest(response)
Пример #9
0
 def test_sync_data_with_modifiedsince_header_ANSI_C_and_not_modified(self):
     date = 'Sun Nov 6 08:49:37 2014'
     store.set('last-update', date)
     response = self.get_manifest_resource(modified=date)
     self.assertNotModified(response)
Пример #10
0
 def test_sync_data_with_modifiedsince_header_RFC_1036_and_in_future(self):
     date = 'Sunday, 06-Nov-14 08:49:37 GMT'
     store.set('last-update', 'Sunday, 06-Nov-13 08:49:37 GMT')
     response = self.get_manifest_resource(modified=date)
     self.assertBadRequest(response)
Пример #11
0
 def test_sync_data_with_modifiedsince_header_RFC_1036_and_not_modified(
         self):
     date = 'Sunday, 06-Nov-14 08:49:37 GMT'
     store.set('last-update', date)
     response = self.get_manifest_resource(modified=date)
     self.assertNotModified(response)
Пример #12
0
 def test_sync_data_with_modifiedsince_header_RFC_1123_and_sync_needed(
         self):
     date = 'Sun, 06 Nov 2014 08:49:37 GMT'
     store.set('last-update', 'Sun, 06 Aug 2015 08:49:37 GMT')
     response = self.get_manifest_resource(modified=date)
     self.assertOk(response)