/// Record void TestModels::test_Record() { QDateTime rdate = QDateTime().currentDateTime(); QString input = "pushup 300"; QStringList result = input.split(" "); QString name = result[0]; QString record_str = result[1]; //int record = record_str.toUInt(); // Returns 0 when failed QVERIFY(ModelAPIs::element(name) != 0); QVERIFY(ModelAPIs::element("pushus") == 0); // Correct input Record record; record.fromInput(input); QVERIFY(record.save() == true); // Input with shortcut QString input_shortcut = "push 500"; Record record_shortcut; record_shortcut.fromInput(input_shortcut); QVERIFY(record_shortcut.save() == true); // Bad record QString input_bad = "pushup 300a"; Record record_to_be_failed; try{ record_to_be_failed.fromInput(input_bad); QVERIFY(false); } catch (exception& e){ QVERIFY(true); } // There is no element QString input_bad2 = "no_element 300"; Record record_to_be_failed2; try{ record_to_be_failed2.fromInput(input_bad2); QVERIFY(false); } catch (exception& e){ QVERIFY(true); } }
void TestModels::test_RecordSchedule() { // Continue test_Record const QDjangoQuerySet<Record> record_set; //qDebug() << record_set.all().values(); QString input = "pushup 500"; Record* record = new Record(); record->fromInput(input); record->save(); // Save // We need the list of today's schedule }