Example #1
0
 def setUp(self):
     self.app = app
     app.config['DATABASE_FOLDER'] = ":memory:"
     app.config['TESTING'] = True
     self.client = app.test_client()
     self.username = u'someguy'
     self.password = u'randopass'
     self.headers = {
         'Content-Type': 'application/json',
         'Authorization': 'Basic ' + base64.b64encode(self.username + ":" + self.password)
     }
Example #2
0
def test_put_event():
    '''
    Check that events can be saved to the server
    '''
    app.config['DATABASE_FOLDER'] = ':memory:'
    app.config['TESTING'] = True
    username = u'hello'
    password = u'world'
    client = app.test_client()
    #TODO: ew.
    flask.g = FakeFlaskGlobal()
    memdam.server.admin.create_archive(username, password)
    event = memdam.common.event.new(NAMESPACE, cpu__number__percent=0.567)
    event_json = json.dumps(event.to_json_dict())
    result = client.put(u'/api/v1/events/' + event.id__id.hex, data=event_json, headers={
        u'Content-Type': u'application/json',
        u'Authorization': u'Basic ' + base64.b64encode(username + u':' + password)
        })
    assert result.status_code == 204