{"id":22177846,"url":"https://github.com/and-sm/testgr","last_synced_at":"2025-07-03T23:37:49.706Z","repository":{"id":33887057,"uuid":"149164578","full_name":"and-sm/testgr","owner":"and-sm","description":"Web service which provides access to Pytest and nose2 test executions data.","archived":false,"fork":false,"pushed_at":"2023-02-15T18:26:05.000Z","size":435,"stargazers_count":15,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-02T06:10:38.509Z","etag":null,"topics":["automation","channels","django","django-channels","nose","nose2","nosetests","pytest","pytest-plugin","python","python3","report","reports","selenium","test-history","testgr","tests","unittest"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/and-sm.png","metadata":{"files":{"readme":"README.md","changelog":"history/__init__.py","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-17T17:45:01.000Z","updated_at":"2022-09-02T11:01:03.000Z","dependencies_parsed_at":"2023-02-18T11:31:18.166Z","dependency_job_id":null,"html_url":"https://github.com/and-sm/testgr","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/and-sm%2Ftestgr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/and-sm%2Ftestgr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/and-sm%2Ftestgr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/and-sm%2Ftestgr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/and-sm","download_url":"https://codeload.github.com/and-sm/testgr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227696688,"owners_count":17805961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","channels","django","django-channels","nose","nose2","nosetests","pytest","pytest-plugin","python","python3","report","reports","selenium","test-history","testgr","tests","unittest"],"created_at":"2024-12-02T08:32:42.378Z","updated_at":"2024-12-02T08:32:43.179Z","avatar_url":"https://github.com/and-sm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Testgr\nWeb service which provides monitoring and data store for nose2 or pytest execution results.\n# How it works\nnose2 and pytest frameworks have several methods for providing details of test runs and tests before and after test execution. To connect **Testgr** and these frameworks - you need to use [**nose2-rt**](https://github.com/and-sm/nose2rt) or [**pytest-rt**](https://github.com/and-sm/pytest-rt) plugins (depending on your framework).\n **Testgr** service collects all data produced by plugins and store it in the database.\nIf some test is in running, passed, failed or skipped state - plugin will send updated data to **Testgr** and user will see test execution status in real-time.\n\n### Main page of Testgr. \n\n![Main page](https://i1.lensdump.com/i/jCCG8K.png)\n\n### Job page. \nOn this page you can review status of your test job execution. \n\n**Job in progress:**\n![Job page](https://i1.lensdump.com/i/jCCaQZ.png)\n\n**Finished job:**\n![Finished_job](https://i.lensdump.com/i/jCCheP.png)\n\n### Example of finished test:\n![Failed test](https://i.lensdump.com/i/0y0ZCQ.png)\n\n### Search:\n![Search](https://i.lensdump.com/i/iUQwLT.png)\n\n\n### Components:\n* Python 3.10.4\n* Django 4.0.4\n* Redis 6.0.16\n* SQLite, MySQL 8 or PostgreSQL 10+\n* Celery 5.2.6\n\n### API plugins setup\nDepending on your test framework (nose2 or pytest) you can choose [**nose2-rt**](https://github.com/and-sm/nose2rt) or [**pytest-rt**](https://github.com/and-sm/pytest-rt).\n\n\n### Deploy and configuration\n1 - \nYou can start up **Testgr** rapidly using docker-compose:\n```\ngit clone https://github.com/and-sm/testgr.git\ncd testgr\n```\n\nIf you are using MySQL - please install **mysqlclient** Python package\n\n2 - \nRename **config_example.env** file to **config.env** and configure:\n\nTESTGR_URL - write http://your_testgr_domain.xx\n\nSECRET_KEY - generate and use strong password\n\nTIME_ZONE - use your timezone, default is UTC\n\nSet up necessary email configuration. Currently Testgr use smtp.EmailBackend as default. \nUse comma delimited emails for more than one email receiver.\n\nOptional: configure **testgr/settings.py** file if more advanced configuration is needed.\n\n3 - Start **Testgr**\n```\ndocker-compose up -d --build\n```\n4 - \nThen you must create an admin user. Let's check information about our running containers:\n```\ndocker ps\n```\nFind **testgr_web** container, remember the CONTAINER ID. Then:\n```\ndocker exec -it TESTGR_WEB_CONTAINER_ID bash\npython manage.py createsuperuser\nexit\n```\n\nOpen **Testgr** by using http://127.0.0.1 address. Login with previously created admin user account.\n\n### User management:\nTo create users go to Management \u003e Users.\nRoles:\n* admin - initial user with full privileges.\n* staff - can create staff/normal users.\n* normal - don't have an access to management page.\n\n### How to stop **Testgr**:\n```\ndocker-compose down\n```\n\n### How to start **Testgr** again:\n```\ndocker-compose up -d\n```\n\n### HTTPS setup\nSSL settings are based on NGINX-LE docker image - https://github.com/nginx-le/nginx-le\n\n1 - \nConfigure necessary settings from \"Deploy and configuration\" section. \n\n2- \nIn the config.env use \"https\" protocol with your URL for TESTGR_URL.\n\n3 - \nOpen docker-compose-ssl and change TZ, LE_EMAIL and LE_FQDN parameters.\n\n4 - \nOpen files in static/js/testgr/main folder and change \"ws://\" to \"wss://\".\n\n5 - \nOpen docker/nginx/testgr_ssl.conf and configure your \"server_name\".\n\n6 - \nRun ```docker-compose -f docker-compose-ssl.yml pull```.\n\n7 - \nRun ```docker-compose -f docker-compose-ssl.yml up``` and go through the LE process.\n\nPlease note, that the very first launch of Testgr can take some additional time, because of SSL dhparams generator.\nWhen you see \"Congratulations! Your cerfificate and chain have been saved...\" - the process must be completed.\n\n**Backup** your SSL certificates, which can be found in testgr/ssl folder\n\n### How to send screenshots from test execution to Testgr\n#### pytest:\nUse **list** with ```t_screen``` name as collection of base64 strings.\n\nExample:\n\n```python\ndef example():\n    chrome_driver.get('https://google.com')\n    pytest.t_screen = []\n    img = chrome_driver.get_screenshot_as_base64()\n    pytest.t_screen.append(img)  # You can add screenshot as list item, name will be generated\n    img2 = chrome_driver.get_screenshot_as_base64()\n    pytest.t_screen.append({\"name\": \"front\", \"image\": img2})  # you can add screenshot as dict item with name\n```\nDo not forget to clear pytest.t_screen before and after each test!\n\nFor example use fixture:\n```python\n@pytest.fixture(autouse=True)\ndef run_around_tests():\n    pytest.t_screen = []\n```\n\n#### Nose2:\nOpen **nose2.cfg** and configure \"screenshots_var\" under ```[rt]``` section.\n\nExample:\n```buildoutcfg\n[rt]\nendpoint = http://example.com/loader\nscreenshot_var = t_screen\n```\n\nThen use **list** with ```t_screen``` name as collection of base64 strings for unittest.TestCase instance.\n\nTest example:\n\n```python\nclass TestScenario(unittest.TestCase):\n\n\tdef setUp(self):\n\t\toptions = webdriver.ChromeOptions() \n\t\tself.driver = webdriver.Chrome(executable_path=\"./chromedriver\", options=options)\n\n\n\tdef test_example(self):\n\t\t\"\"\" description \"\"\"\n\t\tself.assertTrue('FOO'.isupper())\n\t\tself.driver.get(\"https://google.com\")\n\t\tself.t_screen = []\n\t\timg = self.driver.get_screenshot_as_base64()    # You can add screenshot as list item, name will be generated\n\t\tself.t_screen.append(img)\n\t\timg2 = self.driver.get_screenshot_as_base64()\n\t\tself.t_screen.append({\"name\": \"front\", \"image\": img2})  # you can add screenshot as dict item with name\n\n```\n\nScreenshots will be saved in **media/screenshots** folder.\n\n### Custom attachments\n\nIt is possible to send attachments or JSON data to job or test items.\n```bash\ncurl -X POST 'https://{%TESTGR_URL%}/upload/job/{%JOB_UUID%}/' -F 'file=@{%FILE_PATH%}' -H 'Authorization: Token {%USER_TOKEN%}'\n```\n```bash\ncurl -X POST 'https://{%TESTGR_URL%}/upload/test/{%TEST_UUID%}/' -F 'file=@{%FILE_PATH%}' -H 'Authorization: Token {%USER_TOKEN%}'\n```\n```bash\ncurl -X POST 'https://{%TESTGR_URL%}/upload/test/{%TEST_UUID%}/' --data '{\"data\":\"test\"}' -H 'Authorization: Token {%USER_TOKEN%}' -H 'Content-Type: application/json'\n\n```\nUser token can be generated by \"Management -\u003e Users\" page.\nFile types can be configured by config.env ```UPLOAD_MIME_TYPES``` variable.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fand-sm%2Ftestgr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fand-sm%2Ftestgr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fand-sm%2Ftestgr/lists"}