Пример #1
0
    def test_by_name(self):
        assert len(self.dataset.data['views']) == 4

        default = View.by_name(self.dataset, self.dataset, 'default')
        assert default is not None, default
        assert default.entity == 'dataset', default.entity
        assert default.name == 'default', default.name
        assert View.by_name(self.dataset, self.dataset, 'region')

        cf = {'taxonomy': 'cofog'}
        cfa = View.by_name(self.dataset, cf, 'default', 'cofog1')
        assert cfa, cfa
        assert cfa.dimension == 'cofog1', cfa.dimension

        assert_raises(ValueError, View.by_name, self.dataset, cfa, 'not-there')
Пример #2
0
    def test_by_name(self):
        assert len(self.dataset.data['views'])==4

        default = View.by_name(self.dataset, self.dataset, 'default')
        assert default is not None, default
        assert default.entity=='dataset', default.entity
        assert default.name=='default', default.name
        assert View.by_name(self.dataset, self.dataset, 'region')

        cf = {'taxonomy': 'cofog'}
        cfa = View.by_name(self.dataset, cf, 'default', 'cofog1')
        assert cfa, cfa
        assert cfa.dimension=='cofog1', cfa.dimension

        h.assert_raises(ValueError, View.by_name, self.dataset, 
                cfa, 'not-there')
Пример #3
0
    def test_by_name(self):
        view = self.get_view("test1", cuts={"foo": "Hello"})
        view.apply_to(model.entry, {"region": u"ENGLAND_South West"})

        soc = model.entry.find_one({"region": u"ENGLAND_South West"})

        loaded = View.by_name(soc, "test1")
        h.assert_equal(loaded.label, view.label)
        h.assert_equal(loaded.cuts, view.cuts)

        h.assert_raises(ValueError, View.by_name, soc, "not-there")
Пример #4
0
 def timeline(self, id):
     c.dataset = model.Dataset.by_id(id)
     view = View.by_name(c.dataset, "default")
     viewstate = ViewState(c.dataset, view, None)
     data = []
     meta = []
     for entry, year_data in viewstate.aggregates:
         meta.append({"label": entry.get("label"),
                      "description": entry.get("description", ""),
                      "name": entry.get("name"),
                      "index": len(meta),
                      "taxonomy": entry.get("taxonomy")})
         sorted_year_data = sorted(year_data.items(), key=lambda kv: kv[0])
         data.append([{"x": k, "y": v,
                       "meta": len(meta) - 1} for
                      k, v in sorted_year_data])
     c.data = json.dumps(data)
     c.meta = json.dumps(meta)
     return render('dataset/timeline.html')
Пример #5
0
 def timeline(self, name):
     self._get_dataset(name)
     c.dataset = Dataset.by_name(name)
     view = View.by_name(c.dataset, "default")
     viewstate = ViewState(c.dataset, view, None)
     data = []
     meta = []
     for entry, year_data in viewstate.aggregates:
         meta.append({
             "label": entry.get("label"),
             "description": entry.get("description", ""),
             "name": entry.get("name"),
             "index": len(meta),
             "taxonomy": entry.get("taxonomy")
         })
         sorted_year_data = sorted(year_data.items(), key=lambda kv: kv[0])
         data.append([{
             "x": k,
             "y": v,
             "meta": len(meta) - 1
         } for k, v in sorted_year_data])
     c.data = json.dumps(data)
     c.meta = json.dumps(meta)
     return render('dataset/timeline.html')