void TestModels::test_ModelAPIs_lastSchedule() { const QDjangoQuerySet<Schedule> schedule_set; QList< QMap<QString, QVariant> > schedule_map = schedule_set.all().values(); QCOMPARE(schedule_map.last(), ModelAPIs::Instance()->lastSchedule()); }
void TestModels::test_common() { const QDjangoQuerySet<Unit> units; QList< QMap<QString, QVariant> > unit_map = units.all().values(); //QCOMPARE(unit_map.size(), 4); //See initdb() const QDjangoQuerySet<Element> elements; QList< QMap<QString, QVariant> > element_map = elements.all().values(); QCOMPARE(element_map.size(), 3); const QDjangoQuerySet<Group> groups; QList< QMap<QString, QVariant> > group_map = groups.all().values(); QCOMPARE(group_map.size(), 2); const QDjangoQuerySet<ElementGroup> elementgroups; QList< QMap<QString, QVariant> > elementgroup_map = elementgroups.all().values(); QCOMPARE(elementgroup_map.size(), 1); const QDjangoQuerySet<Schedule> schedules; QList< QMap<QString, QVariant> > schedule_map = schedules.all().values(); QCOMPARE(schedule_map.size(), 7); const QDjangoQuerySet<Record> records; QList< QMap<QString, QVariant> > record_map = records.all(). values(); QCOMPARE(record_map.size(), 1); }
void TestModels::test_ModelAPIs_groups() { const QDjangoQuerySet<Group> groups_set; QList< QMap<QString, QVariant> > groups_map = groups_set.all().values(); QList<QString> result; for (int i = 0; i < groups_map.count(); i++){ result << groups_map[i]["name"].toString(); } QList<QString> result2; result2 = ModelAPIs::Instance()->groups(); QCOMPARE(result, result2); }
void TestModels::test_ModelAPIs_elements() { const QDjangoQuerySet<Element> elements_set; QList< QMap<QString, QVariant> > elements_map = elements_set.all().values(); //qDebug() << elements_map; QList<QString> result; for (int i = 0; i < elements_map.count(); i++){ result << elements_map[i]["name"].toString(); } QList<QString> result2; result2 = ModelAPIs::Instance()->elements(); QCOMPARE(result, result2); }
void TestModels::test_ModelAPIs_units() { // Our result const QDjangoQuerySet<Unit> units_set; QList< QList<QVariant> > units = units_set.all().valuesList(); QList<QString> result; for (int i = 0; i < units.count(); i++){ result << units[i][1].toString(); } // From method QList<QString> result2; result2 = ModelAPIs::Instance()->units(); QCOMPARE(result, result2); }
/// ModelAPIs void TestModels::test_ModelAPIs_schedules() { const QDjangoQuerySet<Schedule> schedules_set; QList< QMap<QString, QVariant> > schedule_map = schedules_set.all().values(); QVariantList schedules; schedules = ModelAPIs::Instance()->schedulesToQVariantList(); //qDebug() << schedules; QVERIFY(schedule_map.count() == schedules.count()); // If element_id is null then group_id is the title. QVERIFY(schedules[0].toMap()["title"].toString() == "pushup"); // element title QVERIFY(schedules[1].toMap()["title"].toString() == "daily"); // group title //qDebug() << schedule_map; }