Exemplo n.º 1
0
    def test_validate_slug_uniqness(self, valid_dataset):
        app = Dataset()
        app.slug = valid_dataset.slug

        with pytest.raises(ValidationError) as e:
            app.full_clean()

        assert "'slug':" in str(e.value)
Exemplo n.º 2
0
 def test_create_dataset(self, valid_organization):
     ds = Dataset()
     ds.title = "Title"
     ds.slug = "slug"
     ds.notes = "opis"
     ds.organization = valid_organization
     ds.full_clean()
     assert ds.id is None
     ds.save()
     assert ds.id > 0
Exemplo n.º 3
0
    def test_update_frequency_translations(self, client, valid_organization):
        # MCOD-1031
        for uf_code, readable in UPDATE_FREQUENCY:
            ds = Dataset(slug=f"test-{uf_code}-dataset",
                         title=f"{readable} test name",
                         organization=valid_organization,
                         update_frequency=uf_code)
            ds.save()

            resp = client.simulate_get(f'/datasets/{ds.id}')
            assert HTTP_OK == resp.status
            body = resp.json
            assert readable == body['data']['attributes']['update_frequency']
Exemplo n.º 4
0
def valid_dataset(valid_organization):
    a = Dataset()
    a.slug = "test-dataset-name"
    a.title = "test name"
    a.organization = valid_organization
    a.update_frequency = 'weekly'
    a.save()
    return a
Exemplo n.º 5
0
def create_dataset(param, org):
    dataset = Dataset()
    dataset.slug = param
    dataset.title = param
    dataset.organization = org
    dataset.save()
    return dataset
Exemplo n.º 6
0
def dataset_org2(valid_organization2):
    a = Dataset()
    a.slug = "to-kill"
    a.title = "Zlecenia zabójstw"
    a.organization = valid_organization2
    a.save()
    return a
Exemplo n.º 7
0
def valid_dataset2(valid_organization):
    a = Dataset()
    a.slug = "test-dataset-name2"
    a.title = "test name2"
    a.organization = valid_organization
    a.save()
    return a
Exemplo n.º 8
0
 def test_cant_create_empty_dataset(self):
     with pytest.raises(ValidationError) as e:
         ds = Dataset()
         ds.full_clean()
     assert "'slug'" in str(e.value)
     assert "'title'" in str(e.value)
 def test_is_license_set(self):
     dataset = Dataset()
     assert not dataset.is_license_set
     dataset.license_condition_db_or_copyrighted = "MIT"
     assert dataset.is_license_set