From c98d43bb32f5ebbae191c8b9bca76926a5326fd5 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 31 Jul 2018 13:06:04 -0700 Subject: [PATCH] Problem = last test is created twice. --- tools/auto-tester/src/TestRailInterface.cpp | 55 ++++++++++-------- tools/auto-tester/src/TestRailInterface.h | 9 ++- .../src/ui/TestRailSelectorWindow.cpp | 20 +++++-- .../src/ui/TestRailSelectorWindow.h | 7 ++- .../src/ui/TestRailSelectorWindow.ui | 58 ++++++++++++++++--- 5 files changed, 108 insertions(+), 41 deletions(-) diff --git a/tools/auto-tester/src/TestRailInterface.cpp b/tools/auto-tester/src/TestRailInterface.cpp index 1640918c47..31594fe66a 100644 --- a/tools/auto-tester/src/TestRailInterface.cpp +++ b/tools/auto-tester/src/TestRailInterface.cpp @@ -22,14 +22,15 @@ TestRailInterface::TestRailInterface() { _busyWindow.setModal(true); _testRailSelectorWindow.setModal(true); - ////_testRailSelectorWindow.setURL("https://highfidelity.testrail.net"); - _testRailSelectorWindow.setURL("https://nissimhadar.testrail.io"); - ////_testRailSelectorWindow.setUser("@highfidelity.io"); - _testRailSelectorWindow.setUser("nissim.hadar@gmail.com"); + _testRailSelectorWindow.setURL("https://highfidelity.testrail.net"); + ////_testRailSelectorWindow.setURL("https://nissimhadar.testrail.io"); + _testRailSelectorWindow.setUser("@highfidelity.io"); + ////_testRailSelectorWindow.setUser("nissim.hadar@gmail.com"); - // 24 is the HighFidelity Interface project id in TestRail - ////_testRailSelectorWindow.setProject(24); - _testRailSelectorWindow.setProject(1); + _testRailSelectorWindow.setProjectID(INTERFACE_PROJECT_ID); + ////_testRailSelectorWindow.setProject(1); + + _testRailSelectorWindow.setSuiteID(INTERFACE_SUITE_ID); } QString TestRailInterface::getObject(const QString& path) { @@ -197,9 +198,10 @@ void TestRailInterface::requestTestRailDataFromUser() { _url = _testRailSelectorWindow.getURL() + "/"; _user = _testRailSelectorWindow.getUser(); - ////_password = _testRailSelectorWindow.getPassword(); - _password = "tutKA76"; - _project = QString::number(_testRailSelectorWindow.getProject()); + _password = _testRailSelectorWindow.getPassword(); + ////_password = "tutKA76"; + _projectID = QString::number(_testRailSelectorWindow.getProjectID()); + _suiteID = QString::number(_testRailSelectorWindow.getSuiteID()); } bool TestRailInterface::isAValidTestDirectory(const QString& directory) { @@ -218,7 +220,8 @@ bool TestRailInterface::isAValidTestDirectory(const QString& directory) { void TestRailInterface::processDirectoryPython(const QString& directory, QTextStream& stream, const QString& userGitHub, - const QString& branchGitHub) { + const QString& branchGitHub +) { // Loop over all entries in directory QDirIterator it(directory.toStdString().c_str()); while (it.hasNext()) { @@ -229,9 +232,9 @@ void TestRailInterface::processDirectoryPython(const QString& directory, if (isAValidTestDirectory(nextDirectory)) { // The name of the section is the directory at the end of the path stream << "parent_id = parent_ids.peek()\n"; - stream << "data = { 'name': '" << objectName << "', 'parent_id': parent_id }\n"; + stream << "data = { 'name': '" << objectName << "', 'suite_id': " + _suiteID + ", 'parent_id': parent_id }\n"; - stream << "section = client.send_post('add_section/' + str(" << _project << "), data)\n"; + stream << "section = client.send_post('add_section/' + str(" << _projectID << "), data)\n"; // Now we push the parent_id, and recursively process each directory stream << "parent_ids.push(section['id'])\n\n"; @@ -254,8 +257,8 @@ void TestRailInterface::processDirectoryPython(const QString& directory, // void TestRailInterface::createAddTestCasesPythonScript(const QString& testDirectory, const QString& userGitHub, - const QString& branchGitHub) { - + const QString& branchGitHub +) { QString filename = _outputDirectory + "/addTestCases.py"; if (QFile::exists(filename)) { QFile::remove(filename); @@ -281,9 +284,10 @@ void TestRailInterface::createAddTestCasesPythonScript(const QString& testDirect // top-level section stream << "data = { 'name': '" - << "Test Suite - " << QDateTime::currentDateTime().toString("yyyy-MM-ddTHH:mm") << "'}\n"; + << "Test Suite - " << QDateTime::currentDateTime().toString("yyyy-MM-ddTHH:mm") + "', " + << "'suite_id': " + _suiteID + "}\n"; - stream << "section = client.send_post('add_section/' + str(" << _project << "), data)\n"; + stream << "section = client.send_post('add_section/' + str(" << _projectID << "), data)\n"; // Now we push the parent_id, and recursively process each directory stream << "parent_ids.push(section['id'])\n\n"; @@ -382,7 +386,7 @@ void TestRailInterface::getMilestonesFromTestRail() { // Print the list of uncompleted milestones stream << "file = open('" + _outputDirectory + "/milestones.txt', 'w')\n\n"; - stream << "milestones = client.send_get('get_milestones/" + _project + "')\n"; + stream << "milestones = client.send_get('get_milestones/" + _projectID + "')\n"; stream << "for milestone in milestones:\n"; stream << "\tif milestone['is_completed'] == False:\n"; stream << "\t\tfile.write(milestone['name'] + ' ' + str(milestone['id']) + '\\n')\n\n"; @@ -665,12 +669,15 @@ void TestRailInterface::processTestPython(const QString& fullDirectory, int milestone_id = _milestones[_milestoneNames[_testRailSelectorWindow.getMilestoneID()]]; - stream << "data = {\n\t" - << "'title': '" << title << "',\n\t" - << "'template_id': 2,\n\t" - << "'milestone_id': " << milestone_id << ",\n\t" - << "'custom_preconds': " << "'Tester is in an empty region of a domain in which they have edit rights\\n\\n*Note: Press \\'n\\' to advance test script',\n\t" - << "'custom_steps_separated': " << "[\n\t\t{\n\t\t\t'content': '" << testContent << "',\n\t\t\t'expected': '" << testExpected << "'\n\t\t}\n\t]\n" + stream << "data = {\n" + << "\t'title': '" << title << "',\n" + << "\t'template_id': 2,\n" + << "\t'milestone_id': " << milestone_id << ",\n" + << "\t'custom_tester_count': 1,\n" + << "\t'custom_domain_bot_load': 1,\n" + << "\t'custom_added_to_release': 4,\n" + << "\t'custom_preconds': " << "'Tester is in an empty region of a domain in which they have edit rights\\n\\n*Note: Press \\'n\\' to advance test script',\n" + << "\t'custom_steps_separated': " << "[\n\t\t{\n\t\t\t'content': '" << testContent << "',\n\t\t\t'expected': '" << testExpected << "'\n\t\t}\n\t]\n" << "}\n"; stream << "case = client.send_post('add_case/' + str(section_id), data)\n"; diff --git a/tools/auto-tester/src/TestRailInterface.h b/tools/auto-tester/src/TestRailInterface.h index f7fe131416..4d12145021 100644 --- a/tools/auto-tester/src/TestRailInterface.h +++ b/tools/auto-tester/src/TestRailInterface.h @@ -70,6 +70,12 @@ public: void updateMilestonesComboData(int exitCode, QProcess::ExitStatus exitStatus); private: + // HighFidelity Interface project ID in TestRail + const int INTERFACE_PROJECT_ID{ 24 }; + + // Rendering suite ID + const int INTERFACE_SUITE_ID{ 1147 }; + QDomDocument _document; BusyWindow _busyWindow; @@ -78,7 +84,8 @@ private: QString _url; QString _user; QString _password; - QString _project; + QString _projectID; + QString _suiteID; QString _testDirectory; QString _outputDirectory; diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp b/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp index 9f07c25f3a..afa94b31d0 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp +++ b/tools/auto-tester/src/ui/TestRailSelectorWindow.cpp @@ -16,14 +16,14 @@ TestRailSelectorWindow::TestRailSelectorWindow(QWidget *parent) { setupUi(this); - projectLineEdit->setValidator(new QIntValidator(1, 999, this)); + projectIDLineEdit->setValidator(new QIntValidator(1, 999, this)); } void TestRailSelectorWindow::on_acceptButton_clicked() { urlLineEdit->setDisabled(true); userLineEdit->setDisabled(true); passwordLineEdit->setDisabled(true); - projectLineEdit->setDisabled(true); + projectIDLineEdit->setDisabled(true); OKButton->setDisabled(false); milestoneComboBox->setDisabled(false); @@ -64,12 +64,20 @@ QString TestRailSelectorWindow::getPassword() { return passwordLineEdit->text(); } -void TestRailSelectorWindow::setProject(const int project) { - projectLineEdit->setText(QString::number(project)); +void TestRailSelectorWindow::setProjectID(const int project) { + projectIDLineEdit->setText(QString::number(project)); } -int TestRailSelectorWindow::getProject() { - return projectLineEdit->text().toInt(); +int TestRailSelectorWindow::getProjectID() { + return projectIDLineEdit->text().toInt(); +} + +void TestRailSelectorWindow::setSuiteID(const int project) { + suiteIDLineEdit->setText(QString::number(project)); +} + +int TestRailSelectorWindow::getSuiteID() { + return suiteIDLineEdit->text().toInt(); } void TestRailSelectorWindow::updateMilestoneComboBoxData(QStringList data) { diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.h b/tools/auto-tester/src/ui/TestRailSelectorWindow.h index 7072c1cd46..20bb012723 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.h +++ b/tools/auto-tester/src/ui/TestRailSelectorWindow.h @@ -28,8 +28,11 @@ public: QString getPassword(); - void setProject(const int project); - int getProject(); + void setProjectID(const int project); + int getProjectID(); + + void setSuiteID(const int project); + int getSuiteID(); bool userCancelled{ false }; diff --git a/tools/auto-tester/src/ui/TestRailSelectorWindow.ui b/tools/auto-tester/src/ui/TestRailSelectorWindow.ui index 98c52f3194..5276b458e3 100644 --- a/tools/auto-tester/src/ui/TestRailSelectorWindow.ui +++ b/tools/auto-tester/src/ui/TestRailSelectorWindow.ui @@ -7,7 +7,7 @@ 0 0 489 - 415 + 474 @@ -74,7 +74,7 @@ 120 - 350 + 420 93 28 @@ -87,7 +87,7 @@ 280 - 350 + 420 93 28 @@ -127,7 +127,7 @@ TestRail User - + 200 @@ -155,14 +155,14 @@ - TestRail Project + TestRail Project ID 200 - 220 + 270 231 28 @@ -178,7 +178,7 @@ 270 - 280 + 350 161 22 @@ -191,7 +191,7 @@ 140 - 280 + 350 121 20 @@ -231,8 +231,50 @@ QLineEdit::Normal + + + + 200 + 215 + 231 + 24 + + + + QLineEdit::Normal + + + + + + 70 + 220 + 121 + 20 + + + + + 10 + + + + TestRail Suite ID + + + + urlLineEdit + userLineEdit + passwordLineEdit + projectIDLineEdit + suiteIDLineEdit + acceptButton + milestoneComboBox + OKButton + cancelButton +