def test_apikey_is_unique(self): apikey = str(uuid.uuid4()) app = Application(name='App with UUID', apikey=str(apikey)) app = Application.save(app) app = Application(name='Another app with UUID', apikey=str(apikey)) was_added = True try: Application.save(app) except Exception as e: was_added = False pass assert not was_added
def test_applications_PUT(self): expected_name = 'Veri specil' self.req.swagger_data = {'application': Application(name=expected_name)} httpApps = Applications(self.req) httpApps.applications_POST() app = Application.get_by('name', expected_name) apikey = app.apikey id = app.id self.req.swagger_data = {'id': app.id, 'application': Application(name='', apikey=apikey, id=id)} httpApps.applications_PUT() name_now = Application.get(id).name assert name_now == expected_name
def test_applications_PUT_application_must_exist(self): app = Application(id=42, name='Apperture Science') self.req.swagger_data = {'id': 42, 'application': app} httpApps = Applications(self.req) response = httpApps.applications_PUT() assert response.status_code == 400
def test_applications_POST_apikey_is_set(self): self.req.swagger_data = {'application': Application(name='App 3')} httpApps = Applications(self.req) response = httpApps.applications_POST() expected = Application.get_by('name', 'App 3').as_dict() assert expected['apikey'] is not None
def test_applications_POST(self): self.req.swagger_data = {'application': Application(name='App 3')} httpApps = Applications(self.req) response = httpApps.applications_POST() expected = Application.get_by('name', 'App 3').as_dict() assert response == expected
def test_can_set_apikey(self): apikey = str(uuid.uuid4()) app = Application(name='App with UUID', apikey=str(uuid.uuid4())) app = Application.save(app) expected = Application.get_by('apikey', apikey) assert expected == app
def test_application_POST_name_is_not_empty(self): expected_count = Application.query().count() self.req.swagger_data = {'application': Application(name='')} httpApps = Applications(self.req) response = httpApps.applications_POST() count_now = Application.query().count() assert expected_count == count_now
def test_experimentdistribution_can_be_set(self): app = Application(name='Banana', experiment_distribution='one_random') try: Application.save(app) except Exception as e: pass assert Application.get_by('name', 'Banana') is not None
def test_experimentdistribution_exists(self): experiment_distribution_exists = False app = Application(name='Banana') Application.save(app) app = Application.get_by('name', 'Banana') try: experiment_distribution = app.experiment_distribution experiment_distribution_exists = True except Exception as e: pass assert experiment_distribution_exists
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
def test_save_app(self): app = Application(name='App 3') Application.save(app) appsFromDB = Application.all() assert len(appsFromDB) == 3