def test_destroy_app(self):
     app1 = Application.get(1)
     Application.destroy(app1)
     appsFromDB = Application.all()
     app2 = Application.get(2)
     assert appsFromDB == [app2]
     assert len(appsFromDB) == 1
    def test_create_app(self):
        appsFromDB = Application.all()
        app1 = {
            'id': 1,
            'name': 'App 1'
        }
        app2 = {
            'id': 2,
            'name': 'App 2'
        }
        apps = [app1, app2]

        for i in range(len(appsFromDB)):
            for key in apps[i]:
                assert getattr(appsFromDB[i], key) == apps[i][key]
 def test_save_app(self):
     app = Application(name='App 3')
     Application.save(app)
     appsFromDB = Application.all()
     assert len(appsFromDB) == 3
 def test_get_all_apps(self):
     appsFromDB = Application.all()
     assert len(appsFromDB) == 2
 def test_applications_GET(self):
     httpApps = Applications(self.req)
     response = httpApps.applications_GET()
     expected = list(map(lambda _: _.as_dict(), Application.all()))
     assert response == expected