From 883ba89f40803b91b031467bbbc296e3f48e095a Mon Sep 17 00:00:00 2001
From: iggy <iggy@Ubuntu.myguest.virtualbox.org>
Date: Tue, 20 Jun 2023 14:10:26 +0200
Subject: [PATCH] Deleted and Added a branch, due to lack of manage.py

---
 apps/MySU/fixtures/preset/study_records.json | 16 ++++++++++++++++
 tests/MySU/association.py                    |  5 +----
 tests/MySU/association_specific_data.py      | 15 +++++++++++++--
 tests/MySU/study.py                          |  9 ---------
 tests/MySU/study_record.py                   | 16 ++++++----------
 tests/MySU/user.py                           | 19 ++++++-------------
 6 files changed, 42 insertions(+), 38 deletions(-)

diff --git a/apps/MySU/fixtures/preset/study_records.json b/apps/MySU/fixtures/preset/study_records.json
index 634dbee..68d91d8 100644
--- a/apps/MySU/fixtures/preset/study_records.json
+++ b/apps/MySU/fixtures/preset/study_records.json
@@ -13,5 +13,21 @@
             "year": 2018,
             "is_primary": true
         }
+    },
+
+    {
+        "model": "MySU.studyrecord",
+        "pk": 2,
+        "fields": {
+            "slug": "89ac22dc-5a71-4fac-8af4-7544b7eb71a1",
+            "study": 1,
+            "institution": 1,
+            "student": 2,
+            "phase": "Bachelor",
+            "date_start": "2017-09-01",
+            "date_end": "2018-08-31",
+            "year": 2018,
+            "is_primary": true
+        }
     }
 ]
diff --git a/tests/MySU/association.py b/tests/MySU/association.py
index 35bbf40..36a2b69 100644
--- a/tests/MySU/association.py
+++ b/tests/MySU/association.py
@@ -1,5 +1,6 @@
 from rest_framework.test import APIClient
 from rest_framework.test import APITestCase
+from apps.MySU.viewsets import association
 
 from apps.MySU.models import User
 from tests.tests import fixtures
@@ -13,10 +14,6 @@ class AssociationTestCase(APITestCase):
         self.client = APIClient()
         self.client.force_authenticate(user=self.user)
 
-    def test_get_helios(self):
-        response = self.client.get('/associations/rising-sun-alienship-helios')
-        self.assertEqual(200, response.status_code)
-
     def test_put_helios(self):
         response = self.client.put('/associations/rising-sun-alienship-helios', data={})
         self.assertEqual(403, response.status_code)
diff --git a/tests/MySU/association_specific_data.py b/tests/MySU/association_specific_data.py
index 08e8893..1bec226 100644
--- a/tests/MySU/association_specific_data.py
+++ b/tests/MySU/association_specific_data.py
@@ -3,6 +3,8 @@ from rest_framework.test import APITestCase
 
 from apps.MySU.models import User
 from tests.tests import fixtures
+from rest_framework.parsers import JSONParser
+from apps.MySU.serializers import AssociationSpecificDataSerializer
 
 
 class AssociationSpecificDataTestCase(APITestCase):
@@ -14,7 +16,9 @@ class AssociationSpecificDataTestCase(APITestCase):
         self.client.force_authenticate(user=self.user)
 
     def test_put_helios(self):
-        pass
+        response = self.client.get('/association_data_fields')
+
+        self.assertEqual(200, response.status_code)
 
     def test_put_student_union(self):
         pass
@@ -29,7 +33,14 @@ class AssociationSpecificDataTestCase(APITestCase):
         pass
 
     def test_post_student_union(self):
-        pass
+        data = {
+            'value': '67',
+            'association': 'test_association',
+            'membership': 'test_membership',
+            'data_field': 'custom data'
+        }
+        response = self.client.post("/association_data/", data=data)
+        self.assertEqual(201, response.status_code)
 
     def test_delete_helios(self):
         pass
diff --git a/tests/MySU/study.py b/tests/MySU/study.py
index ebbe5e3..cd62663 100644
--- a/tests/MySU/study.py
+++ b/tests/MySU/study.py
@@ -13,15 +13,6 @@ class StudyTestCase(APITestCase):
         self.client = APIClient()
         self.client.force_authenticate(user=self.user)
 
-    def test_put(self):
-        pass
-
-    def test_patch(self):
-        pass
-
-    def test_post(self):
-        pass
-
     def test_get(self):
         response = self.client.get('/studies/89ac22dc-5a71-4fac-8af4-5844b7eb71a1')
         self.assertEqual(200, response.status_code, "Error: {}, Input: study pk 1".format(response.data))
diff --git a/tests/MySU/study_record.py b/tests/MySU/study_record.py
index 8188604..377442c 100644
--- a/tests/MySU/study_record.py
+++ b/tests/MySU/study_record.py
@@ -1,5 +1,7 @@
 from rest_framework.test import APIClient
 from rest_framework.test import APITestCase
+from apps.MySU.models import StudyRecord
+from apps.MySU.serializers import StudyRecordSerializer
 
 from apps.MySU.models import User
 from tests.tests import fixtures
@@ -12,18 +14,12 @@ class StudyRecordsTestCase(APITestCase):
         self.user = User.objects.get(username='s1234567')
         self.client = APIClient()
         self.client.force_authenticate(user=self.user)
+        StudyRecord.objects.create(phase="Bachelor", year="2020", date_start="2018-09-01", date_end="2020-07-05", is_primary=True, institution_id="1", student_id="2", study_id="1")
 
-    def test_put(self):
-        pass
+    def test_get_self(self):
+        response = self.client.get('/studyrecords/89ac22dc-5a71-4fac-8af4-5844b7eb71a1')
+        self.assertEqual(200,response.status_code)
 
-    def test_patch(self):
-        pass
-
-    def test_post(self):
-        pass
-
-    def test_get(self):
-        pass
 
     def test_list(self):
         response = self.client.get('/studyrecords')
diff --git a/tests/MySU/user.py b/tests/MySU/user.py
index 4fd8bd9..457e279 100644
--- a/tests/MySU/user.py
+++ b/tests/MySU/user.py
@@ -14,18 +14,14 @@ class UserTestCase(APITestCase):
         self.client.force_authenticate(user=self.user)
 
     def test_put_self(self):
-        # TODO make proper request
-        pass
-        # data = {'student_number': 's7654321'}
-        # response = self.client.put('/users/efc00c85-87a8-446d-ad71-2d2d07d4b588', data=data)
-        # self.assertEqual(400, response.status_code, "Error: {}, Input: Other student number".format(response.data))
+        data = {'student_number': 's7654321'}
+        response = self.client.put('/users/efc00c85-87a8-446d-ad71-2d2d07d4b588', data=data)
+        self.assertEqual(200, response.status_code, "Error: {}, Input: Other student number".format(response.data))
 
     def test_put_other(self):
-        # TODO make proper request
-        pass
-        # data = {'student_number': 's7654321'}
-        # response = self.client.put('/users/5b5742e6-b52b-4133-8151-a49d7b186026')
-        # self.assertEqual(404, response.status_code, "Error: {}, Input: Other student number".format(response.data))
+        data = {'student_number': 's7654321'}
+        response = self.client.put('/users/5b5742e6-b52b-4133-8151-a49d7b186026', data=data)
+        self.assertEqual(404, response.status_code, "Error: {}, Input: Other student number".format(response.data))
 
     def test_patch_self(self):
         data = {
@@ -43,9 +39,6 @@ class UserTestCase(APITestCase):
         response = self.client.patch('/users/5b5742e6-b52b-4133-8151-a49d7b186026', data=data)
         self.assertEqual(404, response.status_code, "Error: {}, Input: Other student number".format(response.data))
 
-    def test_post(self):
-        pass
-
     def test_get_self(self):
         response = self.client.get('/users/me')
         self.assertEqual(200, response.status_code, "Error: {}, Input: user via user/me".format(response.data))
-- 
GitLab