Ejemplo n.º 1
0
    def test_shows_app_key(self, client, auth):
        user = make_user()
        auth.login(user)

        response = client.get('users/application_key')

        assert bytes(user.application_key(), 'utf-8') in response.data
Ejemplo n.º 2
0
    def test_succeeds_with_duplicate_name_but_different_user(
            self, client, auth):
        user1 = make_user()
        user2 = make_user('bob')

        auth.login(user1)
        response = client.post('experiments/create',
                               follow_redirects=True,
                               data=dict(name='my experiment',
                                         description='Something'))
        assert (b"Experiment created" in response.data)

        auth.login(user2)
        response = client.post('experiments/create',
                               follow_redirects=True,
                               data=dict(name='my experiment',
                                         description='Something else'))
        assert (b"Experiment created" in response.data)
Ejemplo n.º 3
0
    def test_succeeds_without_description(self, client, auth):
        user = make_user()
        auth.login(user)

        response = client.post('experiments/create',
                               follow_redirects=True,
                               data=dict(name='experiment', description=''))

        assert (b"Experiment created" in response.data)
Ejemplo n.º 4
0
    def test_fails_without_name(self, client, auth):
        user = make_user()
        auth.login(user)

        response = client.post('experiments/create',
                               follow_redirects=True,
                               data=dict(name='', description='Something'))

        assert (b"Experiment.name is required" in response.data)
Ejemplo n.º 5
0
    def test_valid_schema(self, client, auth):
        user = make_user()
        auth.login(user)

        schema = {'field_1': "numeric", 'field_2': "numeric"}

        response = client.post('experiments/create',
                               follow_redirects=True,
                               data=dict(name='name',
                                         description='test',
                                         **self.schema_to_form_fields(schema)))

        experiment = select(ex for ex in Experiment
                            if ex.name == 'name').first()
        eid = experiment.get_pk().hex

        assert schema == Schema.for_experiment(eid).as_dict()