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_destroy_app_does_not_delete_dataitems(self):
        Application.save(Application(id=47, name='App to delete'))
        app = Application.get(47)
        Experiment.save(Experiment(id=78, application=app, name='Apperture'))
        exp = Experiment.get(78)
        ExperimentGroup.save(ExperimentGroup(id=67, name='GlaDos', experiment=exp))
        eg = ExperimentGroup.get(67)
        Client.save(Client(id=76, clientname='Chell', experimentgroups=[eg]))
        client = Client.get(76)
        DataItem.save(DataItem(key='key1',
               value=10,
               startDatetime=strToDatetime('2016-01-01 00:00:00'),
               endDatetime=strToDatetime('2016-01-01 01:01:01'),
               client=client))

        dataitem_count_before = DataItem.query().count()
        Application.destroy(app)
        dataitem_count_now = DataItem.query().count()

        assert dataitem_count_before == dataitem_count_now