Przeglądaj źródła

Se eliminaron los tests. Dificiles de mantener y mas facil
de implementar con otras frameworks.

Tomas Ponce Gessi 3 lat temu
rodzic
commit
cd63def5e9
1 zmienionych plików z 0 dodań i 88 usunięć
  1. 0 88
      app/api/tests.py

+ 0 - 88
app/api/tests.py

@@ -1,88 +0,0 @@
-from tokenize import Token
-from django.test import TestCase
-from .models import ProgrammedReport
-import json
-
-
-# Setear con un token valido antes de ejecutar los tests.
-TOKEN = "335049bcd9936452b436efb61b91eeabbede8a03"
-USER_ID = "1"
-
-# Tests simples de los endpoints del microservicio.
-# No deben ser usados unicamente para garantizar la funcionalidad del sistema.
-# Son dificiles de mantener,lentos de desarollar y no proveen mucha informacion mas haya de lo basico.
-
-
-class ProgrammedReportTest(TestCase):
-
-    # Setup some Programmed Reports for testing.
-    def setUp(self):
-        ProgrammedReport(user_id=USER_ID, report_type="Report Type!", modules=[
-            "module1!"], notified_emails=["email@email.com"]).save()
-        ProgrammedReport(user_id=USER_ID, report_type="Report Type 2!", modules=[
-            "module1!"], notified_emails=["email@email.com"]).save()
-        ProgrammedReport(user_id=USER_ID, report_type="Report Type 3!", modules=[
-            "module1!"], notified_emails=["email@email.com"]).save()
-        ProgrammedReport(user_id="99999", report_type="Report Type 4!", modules=[
-            "module1!", "module2!"], notified_emails=["email@email.com"]).save()
-        pass
-
-    # Test GET (list) request on a particular Programmed Report. URL: /api/preports
-    def test_list_programmed_reports(self):
-        # Retrieve all Programmed Reports and parse them.
-        response = self.client.get(
-            '/api/preports/', HTTP_AUTHORIZATION=TOKEN)
-        self.assertEqual(response.status_code, 200)
-        data = json.loads(response.content)
-
-        # Check if all user_id=123 reports only where retrieved.
-        self.assertEqual(len(data), 3)
-
-        # Check integrity of all the Programmed Reports
-        for item in data:
-            self.assertEqual(
-                check_programmed_report_data_integrity(item, USER_ID), True)
-        return True
-
-    # Test GET (retrieve) request on a particular Programmed Report. URL: /api/preports/{id}/
-    def test_retrieve_programmed_report(self):
-        # Retrieve all Programmed Reports and parse them.
-        response = self.client.get(
-            '/api/preports/', HTTP_AUTHORIZATION=TOKEN)
-        self.assertEqual(response.status_code, 200)
-        data = json.loads(response.content)
-        self.assertGreater(len(data), 0)
-
-        # Use the ID of the first one to retrieve only that report.
-        response = self.client.get(
-            '/api/preports/' + str(data[0]["id"]) + '/',
-            CONTENT_TYPE='application/json', HTTP_AUTHORIZATION=TOKEN)
-
-        # Check if all went okey, including data integrity.
-        self.assertEqual(response.status_code, 200)
-        data = json.loads(response.content)
-        self.assertEqual(
-            check_programmed_report_data_integrity(data, USER_ID), True)
-        return True
-
-    def test_create_programmed_report(self):
-
-        response = self.client.post('/api/preports/', {
-            "user_id": USER_ID,
-            "report_type": "sometype",
-            "modules": json.dumps(["module1"]),
-            "notified_emails": json.dumps(["test@email.com"])
-        }, HTTP_AUTHORIZATION=TOKEN)
-        self.assertEqual(response.status_code, 201)
-        pass
-
-
-def check_programmed_report_data_integrity(data, user_id=None):
-    result = True
-    if (user_id != None):
-        result = data["user_id"] == user_id
-    result = result and len(data["modules"]) > 0 and isinstance(
-        data["modules"][0], str)
-    result = result and len(data["notified_emails"]) > 0 and isinstance(
-        data["notified_emails"][0], str)
-    return result