Пример #1
0
 def testGetEmptyStatus(self):
     exp = SyncedExperiment(experiment=self.exp,
                            uid=self.uid,
                            provider_url=self.url)
     exp.save()
     d = exp.status()
     self.assertEqual(d, None)
Пример #2
0
 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)
Пример #3
0
 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')
Пример #4
0
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()
Пример #5
0
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()
Пример #6
0
    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)
Пример #7
0
    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)
Пример #8
0
 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)
Пример #9
0
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)
Пример #10
0
 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)
Пример #11
0
 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')
Пример #12
0
 def testGetEmptyStatus(self):
     exp = SyncedExperiment(
             experiment=self.exp, uid=self.uid, provider_url=self.url)
     exp.save()
     d = exp.status()
     self.assertEqual(d, None)