Ejemplo n.º 1
0
    def test_shows_public_datasets_with_a_couple(self, cb):
        (d1, d2) = make_samples_datasets()

        r = cb.get('wizard:challenge:data.pick', pk=cb.pk)
        pds = r.context['public_datasets']

        assert pds.count() == 2
        assert d1 in pds
        assert d2 in pds
Ejemplo n.º 2
0
    def test_when_select_public_dataset_returns_to_regular_data(self, cb):
        samples = make_samples_datasets()
        s = samples[0]

        r = cb.post('wizard:challenge:data.pick',
                    pk=cb.pk,
                    data={
                        'kind': 'public',
                        'dataset': s.pk
                    })
        assert_redirects(r, sreverse('wizard:challenge:data', pk=cb.pk))
Ejemplo n.º 3
0
def cb_and_public_data(cb):
    samples = make_samples_datasets()
    s = samples[0]
    cb.post('wizard:challenge:data.pick',
            pk=cb.pk,
            data={
                'kind': 'public',
                'dataset': s.pk
            })
    cb.sample = s

    yield cb
Ejemplo n.º 4
0
    def test_shows_form_pick_public_datasets(self, cb):
        samples = make_samples_datasets()

        r = cb.get('wizard:challenge:data.pick', pk=cb.pk)

        s = r.html.select_one('.pick .public form select')
        options = s.select('option')
        options_txt = [x.text for x in options]

        assert len(options) == len(samples)
        for s in samples:
            assert s.name in options_txt
Ejemplo n.º 5
0
def test_pick_public_dataset_automatically_sets_task(cb):
    samples = make_samples_datasets()
    s = samples[0]

    cb.post('wizard:challenge:data.pick',
            pk=cb.pk,
            data={
                'kind': 'public',
                'dataset': s.pk
            })

    r = cb.get('wizard:challenge:task', pk=cb.pk)
    x = models.TaskModel.objects.get(dataset=s)
    assert r.context['task'] == x
Ejemplo n.º 6
0
def test_get_with_dataset_returns_200(cb):
    samples = make_samples_datasets()
    s = samples[0]

    cb.post('wizard:challenge:data.pick',
            pk=cb.pk,
            data={
                'kind': 'public',
                'dataset': s.pk
            })

    r = cb.get('wizard:challenge:task', pk=cb.pk)

    assert r.status_code == 200
Ejemplo n.º 7
0
    def test_once_picked_returning_to_picker_allows_you_to_pick_another(
            self, cb_and_public_data):
        samples = make_samples_datasets()
        s = samples[-1]

        assert s != cb_and_public_data.sample

        r = cb_and_public_data.post('wizard:challenge:data.pick',
                                    pk=cb_and_public_data.pk,
                                    data={
                                        'kind': 'public',
                                        'dataset': s.pk
                                    })

        assert_redirects(
            r, sreverse('wizard:challenge:data', pk=cb_and_public_data.pk))
Ejemplo n.º 8
0
    def test_once_picked_picking_another_update_page(self, cb_and_public_data):
        samples = make_samples_datasets()
        s = samples[-1]

        assert s != cb_and_public_data.sample

        cb_and_public_data.post('wizard:challenge:data.pick',
                                pk=cb_and_public_data.pk,
                                data={
                                    'kind': 'public',
                                    'dataset': s.pk
                                })

        r = cb_and_public_data.get('wizard:challenge:data',
                                   pk=cb_and_public_data.pk)

        context = r.context

        assert 'form' in context
        assert context['form'].initial['name'] == s.name