-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/SELab-2/UGent-4 into dev…
…elop
- Loading branch information
Showing
51 changed files
with
5,534 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
node_modules | ||
projectenv | ||
venv | ||
.idea | ||
/venv/ | ||
**/__pycache__/ | ||
migrations | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
# UGent-4 | ||
# UGent-4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from django.contrib.auth.models import User | ||
from api.models.gebruiker import Gebruiker | ||
import factory | ||
|
||
class UserFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = User | ||
|
||
username = factory.Sequence(lambda n: f'user{n}') | ||
password = factory.PostGenerationMethodCall('set_password', 'password') | ||
|
||
class GebruikerFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = Gebruiker | ||
|
||
user = factory.SubFactory(UserFactory) | ||
is_lesgever = False |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from django.test import TestCase | ||
from api.models.gebruiker import Gebruiker | ||
from django.contrib.auth.models import User | ||
|
||
class GebruikerTestCase(TestCase): | ||
def setUp(self): | ||
user1 = User.objects.create_user(username='user1') | ||
user2 = User.objects.create_user(username='user2') | ||
Gebruiker.objects.create(user=user1, is_lesgever=False) | ||
Gebruiker.objects.create(user=user2, is_lesgever=True) | ||
|
||
def test_gebruiker_is_lesgever(self): | ||
user1 = Gebruiker.objects.get(user__username='user1') | ||
user2 = Gebruiker.objects.get(user__username='user2') | ||
self.assertEqual(user1.is_lesgever, False) | ||
self.assertEqual(user2.is_lesgever, True) | ||
|
||
def test_user_label(self): | ||
user = Gebruiker.objects.get(user__username='user1') | ||
field_label = user._meta.get_field('user').verbose_name | ||
self.assertEqual(field_label, 'user') | ||
|
||
def test_subjects_label(self): | ||
user = Gebruiker.objects.get(user__username='user1') | ||
field_label = user._meta.get_field('subjects').verbose_name | ||
self.assertEqual(field_label, 'subjects') | ||
|
||
def test_str_method(self): | ||
gebruiker = Gebruiker.objects.get(user__username='user1') | ||
expected_object_name = gebruiker.user.first_name | ||
self.assertEqual(str(gebruiker), expected_object_name) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from django.test import TestCase | ||
from rest_framework.test import APITestCase | ||
from rest_framework.exceptions import ValidationError | ||
from api.models.gebruiker import Gebruiker | ||
from api.serializers.gebruiker import GebruikerSerializer | ||
from django.contrib.auth.models import User | ||
from api.models.vak import Vak | ||
|
||
class GebruikerSerializerTest(APITestCase): | ||
|
||
def setUp(self): | ||
# Create a User instance | ||
self.user = User.objects.create_user(username='testuser') | ||
|
||
self.gebruiker_attributes = { | ||
'user': self.user, | ||
} | ||
|
||
self.serializer_data = GebruikerSerializer().data | ||
self.gebruiker = Gebruiker.objects.create(**self.gebruiker_attributes) | ||
|
||
subjects = [1, 2] | ||
for subject in subjects: | ||
vak = Vak.objects.create(name=subject) | ||
self.gebruiker.subjects.add(vak) | ||
|
||
self.serializer = GebruikerSerializer(instance=self.gebruiker) | ||
|
||
def test_contains_expected_fields(self): | ||
data = self.serializer.data | ||
self.assertCountEqual(data.keys(), ['user', 'is_lesgever', 'subjects']) | ||
|
||
def test_user_field_content(self): | ||
data = self.serializer.data | ||
self.assertEqual(data['user'], self.user.id) | ||
|
||
def test_subjects_field_content(self): | ||
data = self.serializer.data | ||
subjects = [subject.pk for subject in self.gebruiker.subjects.all()] | ||
self.assertEqual(data['subjects'], subjects) | ||
|
||
def test_validation_for_blank_items(self): | ||
serializer = GebruikerSerializer(data={'name': '', 'subjects': []}) | ||
self.assertRaises(ValidationError, serializer.is_valid, raise_exception=True) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
''' from django.test import TestCase | ||
from django.urls import reverse | ||
class TestViews(TestCase): | ||
def test_should_show_register_page(self): | ||
#self.client.get(reverse('register')) | ||
#self.assertEqual(response.status_code, 200) | ||
#self.assertTemplateUsed(response, "authentication/register") | ||
self.assertTrue(True) ''' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from rest_framework.test import APIClient, APITestCase | ||
from api.tests.factories.gebruiker import GebruikerFactory, UserFactory | ||
from django.urls import reverse | ||
|
||
|
||
class GebruikerListViewTest(APITestCase): | ||
def setUp(self): | ||
self.client = APIClient() | ||
self.gebruiker = GebruikerFactory.create() | ||
|
||
def test_get_gebruiker_list(self): | ||
response = self.client.get('/api/gebruikers/') | ||
self.assertEqual(response.status_code, 200) | ||
|
||
def test_post_gebruiker_list(self): | ||
data = {'user': UserFactory.create().id, 'is_lesgever': True} | ||
response = self.client.post('/api/gebruikers/', data) | ||
self.assertEqual(response.status_code, 201) | ||
|
||
|
||
class GebruikerDetailViewTest(APITestCase): | ||
def setUp(self): | ||
self.client = APIClient() | ||
self.gebruiker = GebruikerFactory.create() | ||
self.url = reverse('gebruiker_detail', kwargs={'id': self.gebruiker.user.id}) | ||
|
||
def test_get_gebruiker_detail(self): | ||
response = self.client.get(self.url) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response.data['user'], self.gebruiker.user.id) | ||
|
||
def test_put_gebruiker_detail(self): | ||
data = {'user': self.gebruiker.user.id, 'is_lesgever': True, 'subjects': []} | ||
response = self.client.put(self.url, data) | ||
self.assertEqual(response.status_code, 200) | ||
#self.assertEqual(response.data['is_lesgever'], True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:react-hooks/recommended', | ||
], | ||
ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['react-refresh'], | ||
rules: { | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# React + TypeScript + Vite | ||
|
||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
|
||
Currently, two official plugins are available: | ||
|
||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh | ||
|
||
## Expanding the ESLint configuration | ||
|
||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: | ||
|
||
- Configure the top-level `parserOptions` property like this: | ||
|
||
```js | ||
export default { | ||
// other rules... | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
project: ['./tsconfig.json', './tsconfig.node.json'], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
} | ||
``` | ||
|
||
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` | ||
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` | ||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + React + TS</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="./src/main.tsx"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.