def testGetEmptyStatus(self): exp = SyncedExperiment(experiment=self.exp, uid=self.uid, provider_url=self.url) exp.save() d = exp.status() self.assertEqual(d, None)
def testSetStatus(self): d = { "key": "value" } exp = SyncedExperiment( experiment=self.exp, uid=self.uid, provider_url=self.url) exp.save() exp.save_status(d) json_d = json.loads(exp.msg) self.assertEqual(d, json_d)
def testGetStatus(self): json_str = '{"key": "value"}' exp = SyncedExperiment( experiment=self.exp, uid=self.uid, provider_url=self.url) exp.msg = json_str exp.save() d = exp.status() self.assertIsInstance(d, dict) self.assertEqual(d['key'], 'value')
def testSetStatus(self): d = {"key": "value"} exp = SyncedExperiment(experiment=self.exp, uid=self.uid, provider_url=self.url) exp.save() exp.save_status(d) json_d = json.loads(exp.msg) self.assertEqual(d, json_d)
def notify_experiment(request, uid): """Recive notification that an experiment has been ingested. :param uid: a unique id of the experiment generated by the provider :rtype :class:'django.https.HttpResponse' """ # TODO exp = SyncedExperiment(uid=uid) exp.save()
def testGetStatus(self): json_str = '{"key": "value"}' exp = SyncedExperiment(experiment=self.exp, uid=self.uid, provider_url=self.url) exp.msg = json_str exp.save() d = exp.status() self.assertIsInstance(d, dict) self.assertEqual(d['key'], 'value')
def transitionCheck(self, initial_state, expected_state): self.exp.id = 0 self.exp.save() exp = SyncedExperiment( experiment=self.exp, uid=self.uid, provider_url=self.url) self.uid += 1 exp.state = initial_state() exp.save() clock_tick() new = SyncedExperiment.objects.all()[0] print 'Old state ->', initial_state() print 'New state ->', new.state print 'Expected ->', expected_state(), self.assertIsInstance(new.state, expected_state)
def transitionCheck(self, initial_state, expected_state): self.exp.id = 0 self.exp.save() exp = SyncedExperiment(experiment=self.exp, uid=self.uid, provider_url=self.url) self.uid += 1 exp.state = initial_state() exp.save() clock_tick() new = SyncedExperiment.objects.all()[0] print 'Old state ->', initial_state() print 'New state ->', new.state print 'Expected ->', expected_state(), self.assertIsInstance(new.state, expected_state)
class ManagerTestCase(TestCase): def setUp(self): self.user = User(username='******', password='******', email='*****@*****.**') self.user.save() self.exp = Experiment(approved=True, title='title1', institution_name='institution1', description='description1', created_by=self.user, public_access=Experiment.PUBLIC_ACCESS_FULL) self.exp.save() self.sync_exp = SyncedExperiment(experiment=self.exp, uid='test.1', provider_url='http://somewhere.com') self.sync_exp.save() self.site_manager = flexmock() flexmock(SiteManager).new_instances(self.site_manager) self.Http = flexmock() flexmock(Http).new_instances(self.Http)
class ManagerTestCase(TestCase): def setUp(self): self.user = User(username='******', password='******', email='*****@*****.**') self.user.save() self.exp = Experiment( approved = True, title = 'title1', institution_name = 'institution1', description = 'description1', created_by = self.user, public_access = Experiment.PUBLIC_ACCESS_FULL ) self.exp.save() self.sync_exp = SyncedExperiment( experiment=self.exp, uid='test.1', provider_url='http://somewhere.com') self.sync_exp.save() self.site_manager = flexmock() flexmock(SiteManager).new_instances(self.site_manager) self.Http = flexmock() flexmock(Http).new_instances(self.Http)
def testGetEmptyStatus(self): exp = SyncedExperiment( experiment=self.exp, uid=self.uid, provider_url=self.url) exp.save() d = exp.status() self.assertEqual(d, None)