Exemple #1
0
    def test_reftuple(self):

        Power = reftuple('Power', 'bike, weight')
        power = Power('#Bike', '$Weight')

        with NamedTemporaryFile() as f:
            args, db = bootstrap_file(f, m(V), '5')
            with db.session_context() as s:
                source = Source(type=SourceType.SOURCE)
                s.add(source)
                StatisticJournalText.add(s, 'Bike', None, None, self, None,
                                         source, '{"mass": 42}', '1980-01-01')
                StatisticJournalFloat.add(s, 'Weight', None, None, self, None,
                                          source, 13, '1980-01-01')
            p = power.expand(self.log, s, '1990-01-01', owner=self)
            self.assertEqual(p.weight, 13)
            self.assertEqual(p.bike['mass'], 42)
Exemple #2
0
    def test_reftuple(self):

        Power = reftuple('Power', 'bike, weight')
        power = Power('${bike}', '${weight}')

        with TemporaryDirectory() as f:
            args, data = bootstrap_dir(f, m(V), '5')
            with data.db.session_context() as s:
                source = Source(type=SourceType.SOURCE)
                s.add(source)
                StatisticJournalText.add(s, 'Bike', None, None, self, source,
                                         '{"mass": 42}', '1980-01-01')
                StatisticJournalFloat.add(s, 'Weight', None, None, self,
                                          source, 13, '1980-01-01')
            p = power.expand(s, '1990-01-01', default_owner=self)
            p = p._replace(bike=loads(p.bike))
            self.assertEqual(p.weight, 13)
            self.assertEqual(p.bike['mass'], 42)