Ejemplo n.º 1
0
 def test_import_1(self):
     """ empty weight field is ignored on import => no dataset
     """
     xdata = StringIO.StringIO(u"<w>"
                               "<days><day date=\"2012-06-02\">"
                               "</day></days>"
                               "</w>")
     utils.import_weight_from_xml(xdata, u'user1')
     wx = datetime.datetime.strptime('2012-06-02',
                                     '%Y-%m-%d').date()
     we1 = models.Weight.query.filter_by(wdate=wx).all()
     self.assertEqual(len(we1), 0)
Ejemplo n.º 2
0
 def test_import_2(self):
     """ import without scale set. scales should be None.
     """
     xdata = StringIO.StringIO(u"<w>"
                               "<days><day date=\"2012-06-02\">"
                               "<weight>10</weight>"
                               "</day></days>"
                               "</w>")
     utils.import_weight_from_xml(xdata, u'user1')
     wx = datetime.datetime.strptime('2012-06-02',
                                     '%Y-%m-%d').date()
     we1 = models.Weight.query.filter_by(wdate=wx).all()
     self.assertEqual(len(we1), 1)
     self.assertEqual(we1[0].scales, None)
Ejemplo n.º 3
0
def add_some_data(username):
    # add testuser
    u1 = models.User(username=username)
    u1.set_password(utils.new_pw())
    db.session.add(u1)
    db.session.flush()
    db.session.commit()

    xdata = StringIO.StringIO(u"<w>"
                              "<scales><item id=\"sid1\">"
                              "<owner>o1</owner>"
                              "<model>m1</model>"
                              "</item></scales>"
                              "<days><day date=\"2012-06-03\">"
                              "<weight scale=\"sid1\">50.1</weight>"
                              "</day></days>"
                              "</w>")
    utils.import_weight_from_xml(xdata, username)
Ejemplo n.º 4
0
def import_from_xml(filename, username):
    from utils import import_weight_from_xml
    import_weight_from_xml(filename, username)