From 2f5d6cc5a67c243e77cf6446447c2eef6bdc9507 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Fri, 25 May 2018 18:44:06 +1200
Subject: [PATCH 01/72] Added tests for pikau models.
---
tests/pikau/PikauTestDataGenerator.py | 148 ++++++++++++++++++
tests/pikau/models/test_glossary_model.py | 43 +++++
tests/pikau/models/test_goal_model.py | 43 +++++
tests/pikau/models/test_level_model.py | 43 +++++
tests/pikau/models/test_milestone_model.py | 75 +++++++++
tests/pikau/models/test_pikau_course.py | 60 +++++++
tests/pikau/models/test_pikau_unit_model.py | 82 ++++++++++
.../models/test_progress_outcome_model.py | 62 ++++++++
tests/pikau/models/test_tag_model.py | 43 +++++
tests/pikau/models/test_topic_model.py | 43 +++++
10 files changed, 642 insertions(+)
create mode 100644 tests/pikau/models/test_glossary_model.py
create mode 100644 tests/pikau/models/test_goal_model.py
create mode 100644 tests/pikau/models/test_level_model.py
create mode 100644 tests/pikau/models/test_milestone_model.py
create mode 100644 tests/pikau/models/test_pikau_unit_model.py
create mode 100644 tests/pikau/models/test_progress_outcome_model.py
create mode 100644 tests/pikau/models/test_tag_model.py
create mode 100644 tests/pikau/models/test_topic_model.py
diff --git a/tests/pikau/PikauTestDataGenerator.py b/tests/pikau/PikauTestDataGenerator.py
index 9e97112..ab2b4f1 100644
--- a/tests/pikau/PikauTestDataGenerator.py
+++ b/tests/pikau/PikauTestDataGenerator.py
@@ -5,6 +5,14 @@
from pikau.models import (
PikauCourse,
+ GlossaryTerm,
+ Goal,
+ Tag,
+ Topic,
+ Level,
+ ProgressOutcome,
+ Milestone,
+ PikauUnit,
)
@@ -44,3 +52,143 @@ def create_pikau_course(self, number):
)
pikau_course.save()
return pikau_course
+
+ def create_glossary_term(self, number):
+ """Create GlossaryTerm object.
+
+ Args:
+ number: Identifier of the glossary term (int).
+
+ Returns:
+ GlossaryTerm object.
+ """
+ glossary_term = GlossaryTerm(
+ slug="glossary-term-{}".format(number),
+ term="Glossary Term {}".format(number),
+ description="Description for glossary term {}.
".format(number),
+ )
+ glossary_term.save()
+ return glossary_term
+
+ def create_goal(self, number):
+ """Create Goal object.
+
+ Args:
+ number: Identifier of the goal (int).
+
+ Returns:
+ Goal object.
+ """
+ goal = Goal(
+ slug="goal-{}".format(number),
+ description="Description for goal {}.
".format(number),
+ )
+ goal.save()
+ return goal
+
+ def create_tag(self, number):
+ """Create Tag object.
+
+ Args:
+ number: Identifier of the tag (int).
+
+ Returns:
+ Tag object.
+ """
+ tag = Tag(
+ slug="tag-{}".format(number),
+ name="tag-{}-name".format(number),
+ description="Description for tag {}.
".format(number),
+ )
+ tag.save()
+ return tag
+
+ def create_topic(self, number):
+ """Create Topic object.
+
+ Args:
+ number: Identifier of the topic (int).
+
+ Returns:
+ Topic object.
+ """
+ topic = Topic(
+ slug="topic-{}".format(number),
+ name="topic-{}-name".format(number),
+ )
+ topic.save()
+ return topic
+
+ def create_level(self, number):
+ """Create Level object.
+
+ Args:
+ number: Identifier of the level (int).
+
+ Returns:
+ Level object.
+ """
+ level = Level(
+ slug="level-{}".format(number),
+ name="level-{}-name".format(number),
+ )
+ level.save()
+ return level
+
+ def create_progress_outcome(self, number):
+ """Create Progress Outcome object.
+
+ Args:
+ number: Identifier of the progress outcome (int).
+
+ Returns:
+ Progress Outcome object.
+ """
+ progress_outcome = ProgressOutcome(
+ slug="progress-outcome-{}".format(number),
+ name="progress-outcome-{}-name".format(number),
+ abbreviation="pr-out-{}".format(number),
+ description="Description for progress outcome {}.".format(number),
+ exemplars="progress-outcome-{}".format(number),
+ )
+ progress_outcome.save()
+ return progress_outcome
+
+ def create_milestone(self, number, date):
+ """Create Milestone object.
+
+ Args:
+ number: Identifier of the milestone (int).
+
+ Returns:
+ Milestone object.
+ """
+ milestone = Milestone(
+ name="milestone-{}".format(number),
+ date=date,
+ )
+ milestone.save()
+ return milestone
+
+ def create_pikau_unit(self, pikau_course, number, module_name=False):
+ """Create PikauUnit object.
+
+ Args:
+ number: Identifier of the pikau unit (int).
+
+ Returns:
+ PikauUnit object.
+ """
+ pikau_unit = PikauUnit(
+ slug="pikau-unit-{}".format(number),
+ number=number,
+ pikau_course=pikau_course,
+ name="pikau-unit-{}-name".format(number),
+ # module_name="pikau-unit-{}-module-name".format(number),
+ content="Content for piaku unit {}.
".format(number),
+ )
+ if module_name:
+ pikau_unit.module_name = "pikau-unit-{}-module-name".format(number)
+
+ pikau_unit.save()
+ return pikau_unit
\ No newline at end of file
diff --git a/tests/pikau/models/test_glossary_model.py b/tests/pikau/models/test_glossary_model.py
new file mode 100644
index 0000000..7f8f5c4
--- /dev/null
+++ b/tests/pikau/models/test_glossary_model.py
@@ -0,0 +1,43 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+
+from pikau.models import GlossaryTerm
+
+from django.db import IntegrityError
+
+class GlossaryModelTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.test_data = PikauTestDataGenerator()
+
+ def test_glossary_model_one_glossary_term(self):
+ glossary_term = self.test_data.create_glossary_term(1)
+ query_result = GlossaryTerm.objects.get(slug="glossary-term-1")
+ self.assertEqual(query_result, glossary_term)
+
+ def test_glossary_model_two_glossary_terms(self):
+ glossary_term_1 = self.test_data.create_glossary_term(1)
+ glossary_term_2 = self.test_data.create_glossary_term(2)
+ self.assertQuerysetEqual(
+ GlossaryTerm.objects.all(),
+ [
+ "",
+ ""
+ ],
+ ordered=False
+ )
+
+ def test_glossary_model_uniqueness(self):
+ gloasary_term = self.test_data.create_glossary_term(1)
+ self.assertRaises(
+ IntegrityError,
+ lambda: self.test_data.create_glossary_term(1)
+ )
+
+ def test_glossary_model_str(self):
+ glossary_term = self.test_data.create_glossary_term(1)
+ self.assertEqual(
+ glossary_term.__str__(),
+ "Glossary Term 1"
+ )
diff --git a/tests/pikau/models/test_goal_model.py b/tests/pikau/models/test_goal_model.py
new file mode 100644
index 0000000..aca6e46
--- /dev/null
+++ b/tests/pikau/models/test_goal_model.py
@@ -0,0 +1,43 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+
+from pikau.models import Goal
+
+from django.db import IntegrityError
+
+class GoalModelTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.test_data = PikauTestDataGenerator()
+
+ def test_goal_model_one_goal(self):
+ goal = self.test_data.create_goal(1)
+ query_result = Goal.objects.get(slug="goal-1")
+ self.assertEqual(query_result, goal)
+
+ def test_goal_model_two_goals(self):
+ goal_1 = self.test_data.create_goal(1)
+ goal_2 = self.test_data.create_goal(2)
+ self.assertQuerysetEqual(
+ Goal.objects.all(),
+ [
+ "Description for goal 1.
>",
+ "Description for goal 2.>"
+ ],
+ ordered=False
+ )
+
+ def test_goal_model_uniqueness(self):
+ goal = self.test_data.create_goal(1)
+ self.assertRaises(
+ IntegrityError,
+ lambda: self.test_data.create_goal(1)
+ )
+
+ def test_goal_model_str(self):
+ goal = self.test_data.create_goal(1)
+ self.assertEqual(
+ goal.__str__(),
+ "Description for goal 1.
"
+ )
\ No newline at end of file
diff --git a/tests/pikau/models/test_level_model.py b/tests/pikau/models/test_level_model.py
new file mode 100644
index 0000000..1f663f5
--- /dev/null
+++ b/tests/pikau/models/test_level_model.py
@@ -0,0 +1,43 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+
+from pikau.models import Level
+
+from django.db import IntegrityError
+
+class LevelModelTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.test_data = PikauTestDataGenerator()
+
+ def test_level_model_one_level(self):
+ level = self.test_data.create_level(1)
+ query_result = Level.objects.get(slug="level-1")
+ self.assertEqual(query_result, level)
+
+ def test_level_model_two_levels(self):
+ level_1 = self.test_data.create_level(1)
+ level_2 = self.test_data.create_level(2)
+ self.assertQuerysetEqual(
+ Level.objects.all(),
+ [
+ "",
+ "",
+ ],
+ ordered=False
+ )
+
+ def test_level_model_uniqueness(self):
+ level = self.test_data.create_level(1)
+ self.assertRaises(
+ IntegrityError,
+ lambda: self.test_data.create_level(1)
+ )
+
+ def test_level_model_str(self):
+ level = self.test_data.create_level(1)
+ self.assertEqual(
+ level.__str__(),
+ "level-1-name"
+ )
diff --git a/tests/pikau/models/test_milestone_model.py b/tests/pikau/models/test_milestone_model.py
new file mode 100644
index 0000000..5a04d04
--- /dev/null
+++ b/tests/pikau/models/test_milestone_model.py
@@ -0,0 +1,75 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+
+from pikau.models import Milestone
+
+from django.db import IntegrityError
+from django.template import defaultfilters
+
+import datetime as dt
+from datetime import datetime
+
+class MilestoneModelTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.test_data = PikauTestDataGenerator()
+ self.current_time = datetime.now()
+
+ def test_milestone_model_one_milestone(self):
+ milestone = self.test_data.create_milestone(1, self.current_time)
+ query_result = Milestone.objects.get(name="milestone-1")
+ self.assertEqual(query_result, milestone)
+
+ def test_milestone_model_two_milestones(self):
+ date_1 = self.current_time
+ date_2 = self.current_time + dt.timedelta(days=30)
+ milestone_1 = self.test_data.create_milestone(1, date_1)
+ milestone_2 = self.test_data.create_milestone(2, date_2)
+ self.assertQuerysetEqual(
+ Milestone.objects.all(),
+ [
+ "".format(defaultfilters.date(date_1)),
+ "".format(defaultfilters.date(date_2))
+ ],
+ ordered=False
+ )
+
+ def test_milestone_model_uniqueness(self):
+ date = self.current_time
+ milestone = self.test_data.create_milestone(1, date)
+ self.assertRaises(
+ IntegrityError,
+ lambda: self.test_data.create_milestone(1, date),
+ )
+
+ def test_milestone_model_str(self):
+ date = self.current_time
+ milestone = self.test_data.create_milestone(1, date)
+ self.assertEqual(
+ milestone.__str__(),
+ "milestone-1 - {}".format(defaultfilters.date(date))
+ )
+
+ def test_milestone_model_is_upcoming_future_date(self):
+ future_date = self.current_time + dt.timedelta(days=30)
+ milestone = self.test_data.create_milestone(1, future_date.date())
+ self.assertIs(milestone.is_upcoming, True)
+
+ def test_milestone_model_is_upcoming_past_date(self):
+ past_date = self.current_time - dt.timedelta(days=30)
+ milestone = self.test_data.create_milestone(1, past_date.date())
+ self.assertIs(milestone.is_upcoming, False)
+
+ def test_milestone_model_ordering(self):
+ date_1 = self.current_time
+ date_2 = self.current_time + dt.timedelta(days=30)
+ milestone_1 = self.test_data.create_milestone(1, date_2)
+ milestone_2 = self.test_data.create_milestone(2, date_1)
+ self.assertQuerysetEqual(
+ Milestone.objects.all(),
+ [
+ "".format(defaultfilters.date(date_1)),
+ "".format(defaultfilters.date(date_2))
+ ],
+ )
diff --git a/tests/pikau/models/test_pikau_course.py b/tests/pikau/models/test_pikau_course.py
index 6a62370..e0815fc 100644
--- a/tests/pikau/models/test_pikau_course.py
+++ b/tests/pikau/models/test_pikau_course.py
@@ -1,6 +1,8 @@
from tests.BaseTestWithDB import BaseTestWithDB
from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+import datetime as dt
+from datetime import datetime
class PikauCourseModelTest(BaseTestWithDB):
@@ -14,3 +16,61 @@ def test_pikau_course_str(self):
pikau_course.__str__(),
"Pikau Course 1"
)
+
+ def test_pikau_course_is_overdue_past_milestone_date(self):
+ pikau_course = self.test_data.create_pikau_course(1)
+ milestone_date = datetime.now() - dt.timedelta(days=30)
+ pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
+ self.assertEqual(
+ pikau_course.is_overdue_milestone,
+ True
+ )
+
+ def test_pikau_course_is_overdue_future_milestone_date(self):
+ pikau_course = self.test_data.create_pikau_course(1)
+ milestone_date = datetime.now() + dt.timedelta(days=30)
+ pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
+ self.assertEqual(
+ pikau_course.is_overdue_milestone,
+ False
+ )
+
+ def test_pikau_course_is_overdue_current_milestone_date(self):
+ pikau_course = self.test_data.create_pikau_course(1)
+ milestone_date = datetime.now()
+ pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
+ self.assertEqual(
+ pikau_course.is_overdue_milestone,
+ False
+ )
+
+ def test_pikau_course_is_overdue_course_complete_past_milestone_date(self):
+ pikau_course = self.test_data.create_pikau_course(1)
+ milestone_date = datetime.now() - dt.timedelta(days=30)
+ pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
+ pikau_course.status = 7
+ self.assertEqual(
+ pikau_course.is_overdue_milestone,
+ False
+ )
+
+ def test_pikau_course_is_overdue_course_complete_future_milestone_date(self):
+ pikau_course = self.test_data.create_pikau_course(1)
+ milestone_date = datetime.now() + dt.timedelta(days=30)
+ pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
+ pikau_course.status = 7
+ self.assertEqual(
+ pikau_course.is_overdue_milestone,
+ False
+ )
+
+ def test_pikau_course_is_overdue_course_complete_current_milestone_date(self):
+ pikau_course = self.test_data.create_pikau_course(1)
+ milestone_date = datetime.now()
+ pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
+ pikau_course.status = 7
+ self.assertEqual(
+ pikau_course.is_overdue_milestone,
+ False
+ )
+
diff --git a/tests/pikau/models/test_pikau_unit_model.py b/tests/pikau/models/test_pikau_unit_model.py
new file mode 100644
index 0000000..ace5131
--- /dev/null
+++ b/tests/pikau/models/test_pikau_unit_model.py
@@ -0,0 +1,82 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+
+from pikau.models import PikauUnit
+
+from django.db import IntegrityError
+
+class PikauUnitModelTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.test_data = PikauTestDataGenerator()
+
+ def test_pikau_unit_model_one_unit(self):
+ pikau_course = self.test_data.create_pikau_course("1")
+ pikau_unit = self.test_data.create_pikau_unit(pikau_course, 1)
+ query_result = PikauUnit.objects.get(slug="pikau-unit-1")
+ self.assertEqual(query_result, pikau_unit)
+
+ def test_pikau_unit_model_two_units_with_module_name(self):
+ pikau_course = self.test_data.create_pikau_course("1")
+ pikau_unit_1 = self.test_data.create_pikau_unit(pikau_course, 1, True)
+ pikau_unit_2 = self.test_data.create_pikau_unit(pikau_course, 2, True)
+ self.assertQuerysetEqual(
+ PikauUnit.objects.all(),
+ [
+ "",
+ ""
+ ],
+ ordered=False
+ )
+
+ def test_pikau_unit_model_two_units_without_module_name(self):
+ pikau_course = self.test_data.create_pikau_course("1")
+ pikau_unit_1 = self.test_data.create_pikau_unit(pikau_course, 1)
+ pikau_unit_2 = self.test_data.create_pikau_unit(pikau_course, 2)
+ self.assertQuerysetEqual(
+ PikauUnit.objects.all(),
+ [
+ "",
+ ""
+ ],
+ ordered=False
+ )
+
+ def test_pikau_unit_model_uniqueness(self):
+ pikau_course = self.test_data.create_pikau_course("1")
+ pikau_unit = self.test_data.create_pikau_unit(pikau_course, 1)
+ self.assertRaises(
+ IntegrityError,
+ lambda: self.test_data.create_pikau_unit(pikau_course, 1)
+ )
+
+ def test_pikau_unit_model_str_with_module(self):
+ pikau_course = self.test_data.create_pikau_course("1")
+ pikau_unit = self.test_data.create_pikau_unit(pikau_course, 1, True)
+ self.assertEqual(
+ pikau_unit.__str__(),
+ "Pikau Course 1: pikau-unit-1-module-name - pikau-unit-1-name"
+ )
+
+ def test_pikau_unit_model_str_without_module(self):
+ pikau_course = self.test_data.create_pikau_course("1")
+ pikau_unit = self.test_data.create_pikau_unit(pikau_course, 1)
+ self.assertEqual(
+ pikau_unit.__str__(),
+ "Pikau Course 1: pikau-unit-1-name"
+ )
+
+ def test_pikau_unit_model_ordering(self):
+ pikau_course = self.test_data.create_pikau_course("1")
+ pikau_unit_1 = self.test_data.create_pikau_unit(pikau_course, 1)
+ pikau_unit_2 = self.test_data.create_pikau_unit(pikau_course, 2)
+ pikau_unit_3 = self.test_data.create_pikau_unit(pikau_course, 3)
+ self.assertQuerysetEqual(
+ PikauUnit.objects.all(),
+ [
+ "",
+ "",
+ ""
+ ]
+ )
diff --git a/tests/pikau/models/test_progress_outcome_model.py b/tests/pikau/models/test_progress_outcome_model.py
new file mode 100644
index 0000000..0c4fec3
--- /dev/null
+++ b/tests/pikau/models/test_progress_outcome_model.py
@@ -0,0 +1,62 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+
+from pikau.models import ProgressOutcome
+
+from django.db import IntegrityError
+
+class ProgressOutcomeModelTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.test_data = PikauTestDataGenerator()
+
+ def test_progress_outcome_model_one_progress_outcome(self):
+ progress_outcome = self.test_data.create_progress_outcome(1)
+ query_result = ProgressOutcome.objects.get(slug="progress-outcome-1")
+ self.assertEqual(query_result, progress_outcome)
+
+ def test_progress_outcome_model_two_progress_outcomes(self):
+ progress_outcome_1 = self.test_data.create_progress_outcome(1)
+ progress_outcome_2 = self.test_data.create_progress_outcome(2)
+ self.assertQuerysetEqual(
+ ProgressOutcome.objects.all(),
+ [
+ "",
+ "",
+ ],
+ ordered=False
+ )
+
+ def test_progress_outcome_model_uniqueness(self):
+ progress_outcome = self.test_data.create_progress_outcome(1)
+ self.assertRaises(
+ IntegrityError,
+ lambda: self.test_data.create_progress_outcome(1),
+ )
+
+ def test_progress_outcome_model_str(self):
+ progress_outcome = self.test_data.create_progress_outcome(1)
+ self.assertEqual(
+ progress_outcome.__str__(),
+ "progress-outcome-1-name"
+ )
+
+ # SQLite does not enforce max_length. This test may be used in the future
+ # to validate max_length.
+ #
+ # def test_progress_outcome_model_abbreviation_max_length(self):
+ # abbreviation = "a" * 11 # max length for abbreviation is 10.
+ # self.assertRaises(
+ # IntegrityError,
+ # lambda: ProgressOutcome(
+ # slug="progress-outcome-1",
+ # name="progress-outcome-1-name",
+ # abbreviation=abbreviation,
+ # description="Description for progress outcome 1.",
+ # exemplars="progress-outcome-1",
+ # ),
+ # )
+
+
+
diff --git a/tests/pikau/models/test_tag_model.py b/tests/pikau/models/test_tag_model.py
new file mode 100644
index 0000000..f460659
--- /dev/null
+++ b/tests/pikau/models/test_tag_model.py
@@ -0,0 +1,43 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+
+from pikau.models import Tag
+
+from django.db import IntegrityError
+
+class TagModelTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.test_data = PikauTestDataGenerator()
+
+ def test_tag_model_one_tag(self):
+ tag = self.test_data.create_tag(1)
+ query_result = Tag.objects.get(slug="tag-1")
+ self.assertEqual(query_result, tag)
+
+ def test_tag_model_two_tags(self):
+ tag_1 = self.test_data.create_tag(1)
+ tag_2 = self.test_data.create_tag(2)
+ self.assertQuerysetEqual(
+ Tag.objects.all(),
+ [
+ "",
+ ""
+ ],
+ ordered=False
+ )
+
+ def test_tag_model_uniqueness(self):
+ tag = self.test_data.create_tag(1)
+ self.assertRaises(
+ IntegrityError,
+ lambda: self.test_data.create_tag(1)
+ )
+
+ def test_tag_model_str(self):
+ tag = self.test_data.create_tag(1)
+ self.assertEqual(
+ tag.__str__(),
+ "tag-1-name"
+ )
\ No newline at end of file
diff --git a/tests/pikau/models/test_topic_model.py b/tests/pikau/models/test_topic_model.py
new file mode 100644
index 0000000..eb94deb
--- /dev/null
+++ b/tests/pikau/models/test_topic_model.py
@@ -0,0 +1,43 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+
+from pikau.models import Topic
+
+from django.db import IntegrityError
+
+class TopicModelTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.test_data = PikauTestDataGenerator()
+
+ def test_topic_model_one_topic(self):
+ topic = self.test_data.create_topic(1)
+ query_result = Topic.objects.get(slug="topic-1")
+ self.assertEqual(query_result, topic)
+
+ def test_topic_model_two_topics(self):
+ topic_1 = self.test_data.create_topic(1)
+ topic_2 = self.test_data.create_topic(2)
+ self.assertQuerysetEqual(
+ Topic.objects.all(),
+ [
+ "",
+ "",
+ ],
+ ordered=False
+ )
+
+ def test_topic_model_uniqueness(self):
+ topic = self.test_data.create_topic(1)
+ self.assertRaises(
+ IntegrityError,
+ lambda: self.test_data.create_topic(1)
+ )
+
+ def test_topic_model_str(self):
+ tag = self.test_data.create_topic(1)
+ self.assertEqual(
+ tag.__str__(),
+ "topic-1-name"
+ )
From 7732966ef550e46a9c40712c3e21871fb1eb8ec5 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Mon, 28 May 2018 12:12:32 +1200
Subject: [PATCH 02/72] Add tests for pikau glossary view and pikau goal view.
---
tests/pikau/views/__init__.py | 1 +
tests/pikau/views/test_glossary_view.py | 66 +++++++++++++++++++++++
tests/pikau/views/test_goal_view.py | 69 +++++++++++++++++++++++++
3 files changed, 136 insertions(+)
create mode 100644 tests/pikau/views/__init__.py
create mode 100644 tests/pikau/views/test_glossary_view.py
create mode 100644 tests/pikau/views/test_goal_view.py
diff --git a/tests/pikau/views/__init__.py b/tests/pikau/views/__init__.py
new file mode 100644
index 0000000..25229bc
--- /dev/null
+++ b/tests/pikau/views/__init__.py
@@ -0,0 +1 @@
+"""Module for tests of the views in the pikau application."""
diff --git a/tests/pikau/views/test_glossary_view.py b/tests/pikau/views/test_glossary_view.py
new file mode 100644
index 0000000..874d7a1
--- /dev/null
+++ b/tests/pikau/views/test_glossary_view.py
@@ -0,0 +1,66 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+from django.urls import reverse
+
+
+class GlossaryViewTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.language = "en"
+ self.test_data = PikauTestDataGenerator()
+
+ def test_pikau_glossary_view_with_no_definitions(self):
+ url = reverse("pikau:glossary")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["glossary_terms"]), 0)
+
+ def test_pikau_glossary_view_with_one_definition(self):
+ term = self.test_data.create_glossary_term(1)
+ term.save()
+
+ url = reverse("pikau:glossary")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["glossary_terms"]), 1)
+ self.assertQuerysetEqual(
+ response.context["glossary_terms"],
+ [""]
+ )
+
+ def test_pikau_glossary_view_with_two_definitions(self):
+ term_1 = self.test_data.create_glossary_term(1)
+ term_1.save()
+ term_2 = self.test_data.create_glossary_term(2)
+ term_2.save()
+
+ url = reverse("pikau:glossary")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["glossary_terms"]), 2)
+ self.assertQuerysetEqual(
+ response.context["glossary_terms"],
+ ["", ""]
+ )
+
+ def test_pikau_glossary_view_order(self):
+ term_3 = self.test_data.create_glossary_term(3)
+ term_3.save()
+ term_2 = self.test_data.create_glossary_term(2)
+ term_2.save()
+ term_1 = self.test_data.create_glossary_term(1)
+ term_1.save()
+
+ url = reverse("pikau:glossary")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["glossary_terms"]), 3)
+ self.assertQuerysetEqual(
+ response.context["glossary_terms"],
+ [
+ "",
+ "",
+ ""
+ ]
+ )
diff --git a/tests/pikau/views/test_goal_view.py b/tests/pikau/views/test_goal_view.py
new file mode 100644
index 0000000..ff3c665
--- /dev/null
+++ b/tests/pikau/views/test_goal_view.py
@@ -0,0 +1,69 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+from django.urls import reverse
+
+
+class GoalViewTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.language = "en"
+ self.test_data = PikauTestDataGenerator()
+
+ def test_pikau_goal_view_with_no_goals(self):
+ url = reverse("pikau:goal_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["goals"]), 0)
+
+ def test_pikau_goal_view_with_one_goal(self):
+ goal = self.test_data.create_goal(1)
+ goal.save()
+
+ url = reverse("pikau:goal_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["goals"]), 1)
+ self.assertQuerysetEqual(
+ response.context["goals"],
+ ["Description for goal 1.>"]
+ )
+
+ def test_pikau_goal_view_with_two_goals(self):
+ goal_1 = self.test_data.create_goal(1)
+ goal_1.save()
+ goal_2 = self.test_data.create_goal(2)
+ goal_2.save()
+
+ url = reverse("pikau:goal_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["goals"]), 2)
+ self.assertQuerysetEqual(
+ response.context["goals"],
+ [
+ "Description for goal 1.>",
+ "Description for goal 2.>"
+ ]
+ )
+
+ def test_pikau_goal_view_order(self):
+ goal_3 = self.test_data.create_goal(3)
+ goal_3.save()
+ goal_2 = self.test_data.create_goal(2)
+ goal_2.save()
+ goal_1 = self.test_data.create_goal(1)
+ goal_1.save()
+
+ url = reverse("pikau:goal_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["goals"]), 3)
+ self.assertQuerysetEqual(
+ response.context["goals"],
+ [
+ "Description for goal 1.>",
+ "Description for goal 2.>",
+ "Description for goal 3.>"
+ ]
+ )
\ No newline at end of file
From 94ec6ad5a2e8f8fc9512190a9fa7278f85a1c0d8 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Mon, 28 May 2018 12:22:12 +1200
Subject: [PATCH 03/72] Add tests for pikau level view.
---
tests/pikau/views/test_level_view.py | 69 ++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
create mode 100644 tests/pikau/views/test_level_view.py
diff --git a/tests/pikau/views/test_level_view.py b/tests/pikau/views/test_level_view.py
new file mode 100644
index 0000000..b51eb5f
--- /dev/null
+++ b/tests/pikau/views/test_level_view.py
@@ -0,0 +1,69 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+from django.urls import reverse
+
+
+class LevelViewTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.language = "en"
+ self.test_data = PikauTestDataGenerator()
+
+ def test_pikau_level_view_with_no_levels(self):
+ url = reverse("pikau:level_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["levels"]), 0)
+
+ def test_pikau_level_view_with_one_level(self):
+ level = self.test_data.create_level(1)
+ level.save()
+
+ url = reverse("pikau:level_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["levels"]), 1)
+ self.assertQuerysetEqual(
+ response.context["levels"],
+ [""]
+ )
+
+ def test_pikau_level_view_with_two_levels(self):
+ level_1 = self.test_data.create_level(1)
+ level_1.save()
+ level_2 = self.test_data.create_level(2)
+ level_2.save()
+
+ url = reverse("pikau:level_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["levels"]), 2)
+ self.assertQuerysetEqual(
+ response.context["levels"],
+ [
+ "",
+ "",
+ ]
+ )
+
+ def test_pikau_level_view_order(self):
+ level_3 = self.test_data.create_level(3)
+ level_3.save()
+ level_2 = self.test_data.create_level(2)
+ level_2.save()
+ level_1 = self.test_data.create_level(1)
+ level_1.save()
+
+ url = reverse("pikau:level_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["levels"]), 3)
+ self.assertQuerysetEqual(
+ response.context["levels"],
+ [
+ "",
+ "",
+ ""
+ ]
+ )
\ No newline at end of file
From fe093b60799a6ee8ff6107e82874f4e26bddea85 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Mon, 28 May 2018 13:10:40 +1200
Subject: [PATCH 04/72] Add tests for level detail view.
---
tests/pikau/views/test_level_view.py | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/tests/pikau/views/test_level_view.py b/tests/pikau/views/test_level_view.py
index b51eb5f..5ad2eae 100644
--- a/tests/pikau/views/test_level_view.py
+++ b/tests/pikau/views/test_level_view.py
@@ -10,13 +10,30 @@ def __init__(self, *args, **kwargs):
self.language = "en"
self.test_data = PikauTestDataGenerator()
- def test_pikau_level_view_with_no_levels(self):
+ def test_pikau_level_view_with_valid_slug(self):
+ level = self.test_data.create_level(1)
+ level.save()
+
+ url = reverse("pikau:level", kwargs={"slug": "level-1"})
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(url, "/pikau/levels/level-1/")
+
+ def test_pikau_level_view_with_invalid_slug(self):
+ level = self.test_data.create_level(1)
+ level.save()
+
+ url = reverse("pikau:level", kwargs={"slug": "level-5"})
+ response = self.client.get(url)
+ self.assertEqual(404, response.status_code)
+
+ def test_pikau_level_list_view_with_no_levels(self):
url = reverse("pikau:level_list")
response = self.client.get(url)
self.assertEqual(200, response.status_code)
self.assertEqual(len(response.context["levels"]), 0)
- def test_pikau_level_view_with_one_level(self):
+ def test_pikau_level_list_view_with_one_level(self):
level = self.test_data.create_level(1)
level.save()
@@ -29,7 +46,7 @@ def test_pikau_level_view_with_one_level(self):
[""]
)
- def test_pikau_level_view_with_two_levels(self):
+ def test_pikau_level_list_view_with_two_levels(self):
level_1 = self.test_data.create_level(1)
level_1.save()
level_2 = self.test_data.create_level(2)
@@ -47,7 +64,7 @@ def test_pikau_level_view_with_two_levels(self):
]
)
- def test_pikau_level_view_order(self):
+ def test_pikau_level_list_view_order(self):
level_3 = self.test_data.create_level(3)
level_3.save()
level_2 = self.test_data.create_level(2)
From 8d3eb4d617b1c515f457d110d0d6b39889babae2 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Mon, 28 May 2018 13:35:28 +1200
Subject: [PATCH 05/72] Add tests for pikau tag view.
---
tests/pikau/views/test_tag_view.py | 86 ++++++++++++++++++++++++++++++
1 file changed, 86 insertions(+)
create mode 100644 tests/pikau/views/test_tag_view.py
diff --git a/tests/pikau/views/test_tag_view.py b/tests/pikau/views/test_tag_view.py
new file mode 100644
index 0000000..7ea0628
--- /dev/null
+++ b/tests/pikau/views/test_tag_view.py
@@ -0,0 +1,86 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+from django.urls import reverse
+
+
+class TagViewTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.language = "en"
+ self.test_data = PikauTestDataGenerator()
+
+ def test_pikau_tag_view_with_valid_slug(self):
+ tag = self.test_data.create_tag(1)
+ tag.save()
+
+ url = reverse("pikau:tag", kwargs={"slug": "tag-1"})
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(url, "/pikau/tags/tag-1/")
+
+ def test_pikau_tag_view_with_invalid_slug(self):
+ tag = self.test_data.create_tag(1)
+ tag.save()
+
+ url = reverse("pikau:tag", kwargs={"slug": "tag-5"})
+ response = self.client.get(url)
+ self.assertEqual(404, response.status_code)
+
+ def test_pikau_tag_list_view_with_no_tags(self):
+ url = reverse("pikau:tag_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["tags"]), 0)
+
+ def test_pikau_tag_list_view_with_one_tag(self):
+ tag = self.test_data.create_tag(1)
+ tag.save()
+
+ url = reverse("pikau:tag_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["tags"]), 1)
+ self.assertQuerysetEqual(
+ response.context["tags"],
+ [""]
+ )
+
+ def test_pikau_tag_list_view_with_two_tags(self):
+ tag_1 = self.test_data.create_tag(1)
+ tag_1.save()
+ tag_2 = self.test_data.create_tag(2)
+ tag_2.save()
+
+ url = reverse("pikau:tag_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["tags"]), 2)
+ self.assertQuerysetEqual(
+ response.context["tags"],
+ [
+ "",
+ "",
+ ]
+ )
+
+ def test_pikau_tag_list_view_order(self):
+ tag_3 = self.test_data.create_tag(3)
+ tag_3.save()
+ tag_2 = self.test_data.create_tag(2)
+ tag_2.save()
+ tag_1 = self.test_data.create_tag(1)
+ tag_1.save()
+
+ url = reverse("pikau:tag_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["tags"]), 3)
+ self.assertQuerysetEqual(
+ response.context["tags"],
+ [
+ "",
+ "",
+ ""
+ ]
+ )
\ No newline at end of file
From d086eec47a45ee958466b8924f09096941c7054f Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Mon, 28 May 2018 13:46:25 +1200
Subject: [PATCH 06/72] Add tests for pikau topic view.
---
tests/pikau/views/test_topic_view.py | 87 ++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
create mode 100644 tests/pikau/views/test_topic_view.py
diff --git a/tests/pikau/views/test_topic_view.py b/tests/pikau/views/test_topic_view.py
new file mode 100644
index 0000000..9f60b8a
--- /dev/null
+++ b/tests/pikau/views/test_topic_view.py
@@ -0,0 +1,87 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+from django.urls import reverse
+
+
+class TopicViewTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.language = "en"
+ self.test_data = PikauTestDataGenerator()
+
+ def test_pikau_topic_view_with_valid_slug(self):
+ topic = self.test_data.create_topic(1)
+ topic.save()
+
+ url = reverse("pikau:topic", kwargs={"slug": "topic-1"})
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(url, "/pikau/topics/topic-1/")
+
+ def test_pikau_topic_view_with_invalid_slug(self):
+ topic = self.test_data.create_topic(1)
+ topic.save()
+
+ url = reverse("pikau:topic", kwargs={"slug": "topic-5"})
+ response = self.client.get(url)
+ self.assertEqual(404, response.status_code)
+
+ def test_pikau_topic_list_view_with_no_topics(self):
+ url = reverse("pikau:topic_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["topics"]), 0)
+
+ def test_pikau_topic_list_view_with_one_topic(self):
+ topic = self.test_data.create_topic(1)
+ topic.save()
+
+ url = reverse("pikau:topic_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["topics"]), 1)
+ self.assertQuerysetEqual(
+ response.context["topics"],
+ [""]
+ )
+
+ def test_pikau_topic_list_view_with_two_topics(self):
+ topic_1 = self.test_data.create_topic(1)
+ topic_1.save()
+ topic_2 = self.test_data.create_topic(2)
+ topic_2.save()
+
+ url = reverse("pikau:topic_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["topics"]), 2)
+ self.assertQuerysetEqual(
+ response.context["topics"],
+ [
+ "",
+ "",
+ ]
+ )
+
+
+ def test_pikau_topic_list_view_order(self):
+ topic_3 = self.test_data.create_topic(3)
+ topic_3.save()
+ topic_2 = self.test_data.create_topic(2)
+ topic_2.save()
+ topic_1 = self.test_data.create_topic(1)
+ topic_1.save()
+
+ url = reverse("pikau:topic_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["topics"]), 3)
+ self.assertQuerysetEqual(
+ response.context["topics"],
+ [
+ "",
+ "",
+ ""
+ ]
+ )
\ No newline at end of file
From a0e8549e58126b1d68104fef6cc328cd1dac5df4 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Mon, 28 May 2018 18:38:18 +1200
Subject: [PATCH 07/72] Add test for pikau index view.
---
tests/pikau/views/test_index_view.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100644 tests/pikau/views/test_index_view.py
diff --git a/tests/pikau/views/test_index_view.py b/tests/pikau/views/test_index_view.py
new file mode 100644
index 0000000..b099fb9
--- /dev/null
+++ b/tests/pikau/views/test_index_view.py
@@ -0,0 +1,15 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from django.urls import reverse
+from http import HTTPStatus
+
+
+class IndexViewTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.language = "en"
+
+ def test_index_view(self):
+ response = self.client.get(reverse("pikau:index"))
+ self.assertEqual(HTTPStatus.OK, response.status_code)
+ self.assertContains(response, "Pīkau Content")
From f4cedd9e9d5e1666340210f58f38dbfedaf17382 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Mon, 28 May 2018 18:43:48 +1200
Subject: [PATCH 08/72] Add test for pikau documentation view.
---
tests/pikau/views/test_documentation_view.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100644 tests/pikau/views/test_documentation_view.py
diff --git a/tests/pikau/views/test_documentation_view.py b/tests/pikau/views/test_documentation_view.py
new file mode 100644
index 0000000..15c3db1
--- /dev/null
+++ b/tests/pikau/views/test_documentation_view.py
@@ -0,0 +1,15 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from django.urls import reverse
+from http import HTTPStatus
+
+
+class DocumentationViewTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.language = "en"
+
+ def test_index_view(self):
+ response = self.client.get(reverse("pikau:docs"))
+ self.assertEqual(HTTPStatus.OK, response.status_code)
+ self.assertContains(response, "Pīkau Documentation")
From 1e4f5c2f909c696157e62bee416c533d09180dfc Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 29 May 2018 11:24:45 +1200
Subject: [PATCH 09/72] Fix test function name for pikau documentation view
test.
---
tests/pikau/views/test_documentation_view.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/pikau/views/test_documentation_view.py b/tests/pikau/views/test_documentation_view.py
index 15c3db1..9fb36af 100644
--- a/tests/pikau/views/test_documentation_view.py
+++ b/tests/pikau/views/test_documentation_view.py
@@ -9,7 +9,7 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.language = "en"
- def test_index_view(self):
+ def test_documentation_view(self):
response = self.client.get(reverse("pikau:docs"))
self.assertEqual(HTTPStatus.OK, response.status_code)
self.assertContains(response, "Pīkau Documentation")
From 873c4fef467676de7b6c586c5e65394fe4e5c2a2 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 29 May 2018 11:25:11 +1200
Subject: [PATCH 10/72] Add tests for pikau course view.
---
tests/pikau/views/test_pikau_course_view.py | 82 +++++++++++++++++++++
1 file changed, 82 insertions(+)
create mode 100644 tests/pikau/views/test_pikau_course_view.py
diff --git a/tests/pikau/views/test_pikau_course_view.py b/tests/pikau/views/test_pikau_course_view.py
new file mode 100644
index 0000000..ed84989
--- /dev/null
+++ b/tests/pikau/views/test_pikau_course_view.py
@@ -0,0 +1,82 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+from django.urls import reverse
+
+
+class PikauCourseViewTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.language = "en"
+ self.test_data = PikauTestDataGenerator()
+
+ def test_pikau_course_list_view_with_no_courses(self):
+ url = reverse("pikau:pikau_course_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["pikau_courses"]), 0)
+
+ def test_pikau_course_list_view_with_one_course(self):
+ pikau_course = self.test_data.create_pikau_course(1)
+ pikau_course.save()
+
+ url = reverse("pikau:pikau_course_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["pikau_courses"]), 1)
+ self.assertQuerysetEqual(
+ response.context["pikau_courses"],
+ [""]
+ )
+
+ def test_pikau_course_list_view_with_two_courses(self):
+ pikau_course_1 = self.test_data.create_pikau_course(1)
+ pikau_course_1.save()
+ pikau_course_2 = self.test_data.create_pikau_course(2)
+ pikau_course_2.save()
+
+ url = reverse("pikau:pikau_course_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["pikau_courses"]), 2)
+ self.assertQuerysetEqual(
+ response.context["pikau_courses"],
+ [
+ "",
+ "",
+ ]
+ )
+
+ def test_pikau_course_view_with_valid_slug(self):
+ pikau_course_1 = self.test_data.create_pikau_course(1)
+ pikau_course_1.save()
+
+ url = reverse("pikau:pikau_course", kwargs={"slug": "pikau-course-1"})
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(url, "/pikau/pikau-courses/pikau-course-1/")
+
+ def test_pikau_course_view_with_invalid_slug(self):
+ pikau_course_1 = self.test_data.create_pikau_course(1)
+ pikau_course_1.save()
+
+ url = reverse("pikau:pikau_course", kwargs={"slug": "pikau-course-5"})
+ response = self.client.get(url)
+ self.assertEqual(404, response.status_code)
+
+ def test_pikau_course_content_view_with_valid_slug(self):
+ pikau_course_1 = self.test_data.create_pikau_course(1)
+ pikau_course_1.save()
+
+ url = reverse("pikau:pikau_content", kwargs={"slug": "pikau-course-1"})
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertContains(response, "Pikau Course 1")
+
+ def test_pikau_course_content_view_with_invalid_slug(self):
+ pikau_course_1 = self.test_data.create_pikau_course(1)
+ pikau_course_1.save()
+
+ url = reverse("pikau:pikau_content", kwargs={"slug": "pikau-course-5"})
+ response = self.client.get(url)
+ self.assertEqual(404, response.status_code)
From 403b9ecf765a649f626141068d35251471e0ed8c Mon Sep 17 00:00:00 2001
From: Jack Morgan
Date: Tue, 29 May 2018 20:55:57 +1200
Subject: [PATCH 11/72] Load pikau prerequisites from loader
---
.../metadata.yaml | 2 ++
.../pikau-courses/what-is-computational-thinking/metadata.yaml | 2 ++
pikau/management/commands/_PikauCourseLoader.py | 3 +++
3 files changed, 7 insertions(+)
diff --git a/pikau/content/pikau-courses/computational-thinking-the-international-perspective/metadata.yaml b/pikau/content/pikau-courses/computational-thinking-the-international-perspective/metadata.yaml
index 4f8324f..f485d1f 100644
--- a/pikau/content/pikau-courses/computational-thinking-the-international-perspective/metadata.yaml
+++ b/pikau/content/pikau-courses/computational-thinking-the-international-perspective/metadata.yaml
@@ -7,6 +7,8 @@ tags:
- introductory
cover-photo: images/pikau/ct-around-the-world.png
trailer-video: https://www.youtube.com/embed/zSfzB-Z-mKM
+prerequisites:
+ - what-is-computational-thinking
overview: overview.md
content:
diff --git a/pikau/content/pikau-courses/what-is-computational-thinking/metadata.yaml b/pikau/content/pikau-courses/what-is-computational-thinking/metadata.yaml
index 29ee69c..b452113 100644
--- a/pikau/content/pikau-courses/what-is-computational-thinking/metadata.yaml
+++ b/pikau/content/pikau-courses/what-is-computational-thinking/metadata.yaml
@@ -7,6 +7,8 @@ tags:
- introductory
cover-photo: images/pikau/what-is-ct.png
trailer-video: https://www.youtube.com/embed/zSfzB-Z-mKM
+prerequisites:
+ - getting-the-most-out-of-pikau
overview: overview.md
content:
diff --git a/pikau/management/commands/_PikauCourseLoader.py b/pikau/management/commands/_PikauCourseLoader.py
index 2869b62..6b3bc7a 100644
--- a/pikau/management/commands/_PikauCourseLoader.py
+++ b/pikau/management/commands/_PikauCourseLoader.py
@@ -111,6 +111,9 @@ def load(self):
for pikau_course_glossary_term_slug in pikau_course_metadata.get("glossary", list()):
pikau_course.glossary_terms.add(GlossaryTerm.objects.get(slug=pikau_course_glossary_term_slug))
+ for pikau_course_prerequisite_slug in pikau_course_metadata.get("prerequisites", list()):
+ pikau_course.prerequisites.add(PikauCourse.objects.get(slug=pikau_course_prerequisite_slug))
+
self.log_object_creation(created, pikau_course)
self.log("All pikau courses loaded!\n")
From b1f4f37d059e36309b159a7f4e6dfa26eed94437 Mon Sep 17 00:00:00 2001
From: Jack Morgan
Date: Tue, 29 May 2018 21:44:47 +1200
Subject: [PATCH 12/72] Set readiness-level for pikau
---
.../metadata.yaml | 1 +
.../pikau-courses/getting-the-most-out-of-pikau/metadata.yaml | 1 +
.../pikau-courses/what-is-computational-thinking/metadata.yaml | 1 +
3 files changed, 3 insertions(+)
diff --git a/pikau/content/pikau-courses/computational-thinking-the-international-perspective/metadata.yaml b/pikau/content/pikau-courses/computational-thinking-the-international-perspective/metadata.yaml
index f485d1f..6f20e6d 100644
--- a/pikau/content/pikau-courses/computational-thinking-the-international-perspective/metadata.yaml
+++ b/pikau/content/pikau-courses/computational-thinking-the-international-perspective/metadata.yaml
@@ -1,5 +1,6 @@
name: "Computational thinking - The international perspective"
status: 2
+readiness-level: 1
language: en
topic: ct
level: all
diff --git a/pikau/content/pikau-courses/getting-the-most-out-of-pikau/metadata.yaml b/pikau/content/pikau-courses/getting-the-most-out-of-pikau/metadata.yaml
index 99a2f97..5ee6ce8 100644
--- a/pikau/content/pikau-courses/getting-the-most-out-of-pikau/metadata.yaml
+++ b/pikau/content/pikau-courses/getting-the-most-out-of-pikau/metadata.yaml
@@ -1,5 +1,6 @@
name: "Getting the most out of pīkau"
status: 6
+readiness-level: 1
overview: overview.md
language: en
topic: housekeeping
diff --git a/pikau/content/pikau-courses/what-is-computational-thinking/metadata.yaml b/pikau/content/pikau-courses/what-is-computational-thinking/metadata.yaml
index b452113..65d57e1 100644
--- a/pikau/content/pikau-courses/what-is-computational-thinking/metadata.yaml
+++ b/pikau/content/pikau-courses/what-is-computational-thinking/metadata.yaml
@@ -1,5 +1,6 @@
name: "What is computational thinking?"
status: 5
+readiness-level: 1
language: en
topic: ct
level: all
From bf386dd4cedb703e8e12e8c9a5a0298c825cecf2 Mon Sep 17 00:00:00 2001
From: Jack Morgan
Date: Tue, 29 May 2018 21:45:56 +1200
Subject: [PATCH 13/72] =?UTF-8?q?Ensure=20p=C4=ABkau=20title=20fits=20with?=
=?UTF-8?q?in=20pathway=20diagram=20nodes=20(fixes=20#56)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pikau/utils/pathways.py | 4 ++--
static/js/lite.render.js | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/pikau/utils/pathways.py b/pikau/utils/pathways.py
index 7da2dde..ae23c59 100644
--- a/pikau/utils/pathways.py
+++ b/pikau/utils/pathways.py
@@ -6,8 +6,8 @@
GRAPH_TEMPLATE = (
"digraph {{"
- "graph [bgcolor=transparent,fontname=inherit];"
- "node [shape=box,fillcolor=white,style=filled,fontname=inherit];"
+ 'graph [bgcolor=transparent,fontname="helvetica"];'
+ 'node [shape=box,fillcolor=white,style=filled,fontname="helvetica", margin=0.1];'
"{nodes}"
"{edges}"
"}}"
diff --git a/static/js/lite.render.js b/static/js/lite.render.js
index fc8a76b..bd0fcac 100644
--- a/static/js/lite.render.js
+++ b/static/js/lite.render.js
@@ -1,5 +1,5 @@
/*
-Viz.js 2.0.0-pre.8 (Graphviz 2.40.1, Emscripten 1.37.36)
+Viz.js 2.0.0 (Graphviz 2.40.1, Emscripten 1.37.36)
*/
(function(global) {
var Module = function(Module) {
From 307981927d5db4bacc4e3e6c87e0dd4ecaa21556 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Wed, 30 May 2018 11:07:03 +1200
Subject: [PATCH 14/72] Add tests for pikau readiness level view.
---
.../pikau/views/test_readiness_level_view.py | 176 ++++++++++++++++++
1 file changed, 176 insertions(+)
create mode 100644 tests/pikau/views/test_readiness_level_view.py
diff --git a/tests/pikau/views/test_readiness_level_view.py b/tests/pikau/views/test_readiness_level_view.py
new file mode 100644
index 0000000..ee0f910
--- /dev/null
+++ b/tests/pikau/views/test_readiness_level_view.py
@@ -0,0 +1,176 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+from django.urls import reverse
+
+
+class ReadinessLevelViewTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.language = "en"
+ self.test_data = PikauTestDataGenerator()
+
+ def test_readiness_level_list_view_with_no_courses(self):
+ url = reverse("pikau:readiness_level_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+
+ readiness_levels = response.context["readiness_levels"]
+ for level in range(1, 6):
+ level_data = readiness_levels[level]
+ num_of_courses_on_level = level_data["count"]
+ self.assertEqual(num_of_courses_on_level, 0)
+
+ def test_readiness_level_list_view_with_one_course_for_all_levels(self):
+ # create 1 course under each readiness level
+ for level in range(1, 6):
+ pikau_course = self.test_data.create_pikau_course(level)
+ pikau_course.readiness_level = level
+ pikau_course.save()
+
+ url = reverse("pikau:readiness_level_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+
+ readiness_levels = response.context["readiness_levels"]
+ level_data = readiness_levels[level]
+ num_of_courses_on_level = level_data["count"]
+ self.assertEqual(num_of_courses_on_level, 1)
+
+ def test_readiness_level_list_view_multiple_courses_one_level(self):
+ pikau_course_1 = self.test_data.create_pikau_course(1)
+ pikau_course_1.readiness_level = 4
+ pikau_course_1.save()
+
+ pikau_course_2 = self.test_data.create_pikau_course(2)
+ pikau_course_2.readiness_level = 4
+ pikau_course_2.save()
+
+ pikau_course_3 = self.test_data.create_pikau_course(3)
+ pikau_course_3.readiness_level = 4
+ pikau_course_3.save()
+
+ url = reverse("pikau:readiness_level_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+
+ readiness_levels = response.context["readiness_levels"]
+ level_data = readiness_levels[4]
+ num_of_courses_on_level = level_data["count"]
+ self.assertEqual(num_of_courses_on_level, 3)
+
+ def test_readiness_level_list_view_multiple_courses_multiple_levels(self):
+ pikau_course_1 = self.test_data.create_pikau_course(1)
+ pikau_course_1.readiness_level = 2
+ pikau_course_1.save()
+
+ pikau_course_2 = self.test_data.create_pikau_course(2)
+ pikau_course_2.readiness_level = 5
+ pikau_course_2.save()
+
+ pikau_course_3 = self.test_data.create_pikau_course(3)
+ pikau_course_3.readiness_level = 1
+ pikau_course_3.save()
+
+ pikau_course_4 = self.test_data.create_pikau_course(4)
+ pikau_course_4.readiness_level = 1
+ pikau_course_4.save()
+
+ pikau_course_5 = self.test_data.create_pikau_course(5)
+ pikau_course_5.readiness_level = 2
+ pikau_course_5.save()
+
+ url = reverse("pikau:readiness_level_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+
+ readiness_levels = response.context["readiness_levels"]
+ level_1_data = readiness_levels[1]
+ level_2_data = readiness_levels[2]
+ level_5_data = readiness_levels[5]
+ num_of_courses_on_level_1 = level_1_data["count"]
+ num_of_courses_on_level_2 = level_2_data["count"]
+ num_of_courses_on_level_5 = level_5_data["count"]
+
+ self.assertEqual(num_of_courses_on_level_1, 2)
+ self.assertEqual(num_of_courses_on_level_2, 2)
+ self.assertEqual(num_of_courses_on_level_5, 1)
+
+ def test_readiness_level_view_no_courses(self):
+ url = reverse("pikau:readiness_level", kwargs={"level_number": 2})
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ readiness_level = response.context["readiness_level"]
+ pikau_courses = readiness_level["pikau_courses"]
+ self.assertQuerysetEqual(pikau_courses, [])
+
+ def test_readiness_level_view_one_course(self):
+ pikau_course = self.test_data.create_pikau_course(1)
+ pikau_course.readiness_level = 5
+ pikau_course.save()
+
+ url = reverse("pikau:readiness_level", kwargs={"level_number": 5})
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ readiness_level = response.context["readiness_level"]
+ pikau_courses = readiness_level["pikau_courses"]
+ self.assertQuerysetEqual(
+ pikau_courses,
+ [""]
+ )
+
+ def test_readiness_level_view_two_courses(self):
+ pikau_course_1 = self.test_data.create_pikau_course(1)
+ pikau_course_1.readiness_level = 3
+ pikau_course_1.save()
+
+ pikau_course_2 = self.test_data.create_pikau_course(2)
+ pikau_course_2.readiness_level = 3
+ pikau_course_2.save()
+
+ url = reverse("pikau:readiness_level", kwargs={"level_number": 3})
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ readiness_level = response.context["readiness_level"]
+ pikau_courses = readiness_level["pikau_courses"]
+ self.assertQuerysetEqual(
+ pikau_courses,
+ [
+ "",
+ ""
+ ],
+ ordered=False
+ )
+
+ def test_readiness_level_view_three_courses(self):
+ pikau_course_1 = self.test_data.create_pikau_course(1)
+ pikau_course_1.readiness_level = 4
+ pikau_course_1.save()
+
+ pikau_course_2 = self.test_data.create_pikau_course(2)
+ pikau_course_2.readiness_level = 4
+ pikau_course_2.save()
+
+ pikau_course_3 = self.test_data.create_pikau_course(3)
+ pikau_course_3.readiness_level = 4
+ pikau_course_3.save()
+
+ url = reverse("pikau:readiness_level", kwargs={"level_number": 4})
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ readiness_level = response.context["readiness_level"]
+ pikau_courses = readiness_level["pikau_courses"]
+ self.assertQuerysetEqual(
+ pikau_courses,
+ [
+ "",
+ "",
+ "",
+ ],
+ ordered=False
+ )
+
+ def test_readiness_level_view_with_invalid_level(self):
+ url = reverse("pikau:readiness_level", kwargs={"level_number": 6})
+ response = self.client.get(url)
+ self.assertEqual(404, response.status_code)
From 91ee30f155400eedc2f6119d499c8a54e7d186d4 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Wed, 30 May 2018 14:45:46 +1200
Subject: [PATCH 15/72] Add tests for pikau unit view.
---
tests/pikau/views/test_pikau_unit_view.py | 117 ++++++++++++++++++++++
1 file changed, 117 insertions(+)
create mode 100644 tests/pikau/views/test_pikau_unit_view.py
diff --git a/tests/pikau/views/test_pikau_unit_view.py b/tests/pikau/views/test_pikau_unit_view.py
new file mode 100644
index 0000000..80955d8
--- /dev/null
+++ b/tests/pikau/views/test_pikau_unit_view.py
@@ -0,0 +1,117 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+from django.urls import reverse
+
+
+class PikauUnitViewTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.language = "en"
+ self.test_data = PikauTestDataGenerator()
+
+ def test_pikau_unit_view_with_valid_slug(self):
+ pikau_course = self.test_data.create_pikau_course(1)
+ pikau_unit = self.test_data.create_pikau_unit(pikau_course, 1)
+
+ kwargs = {
+ "course_slug": "pikau-course-1",
+ "unit_slug": "pikau-unit-1"
+ }
+ url = reverse("pikau:pikau_unit", kwargs=kwargs)
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(
+ url,
+ "/pikau/pikau-courses/pikau-course-1/content/pikau-unit-1/"
+ )
+
+ def test_pikau_unit_view_with_invalid_unit_slug(self):
+ pikau_course = self.test_data.create_pikau_course(1)
+ pikau_unit = self.test_data.create_pikau_unit(pikau_course, 1)
+
+ kwargs = {
+ "course_slug": "pikau-course-1",
+ "unit_slug": "pikau-unit-2"
+ }
+ url = reverse("pikau:pikau_unit", kwargs=kwargs)
+ response = self.client.get(url)
+ self.assertEqual(404, response.status_code)
+
+ def test_pikau_unit_view_with_invalid_course_slug(self):
+ pikau_course = self.test_data.create_pikau_course(1)
+ pikau_unit = self.test_data.create_pikau_unit(pikau_course, 1)
+
+ kwargs = {
+ "course_slug": "pikau-course-2",
+ "unit_slug": "pikau-unit-1"
+ }
+ url = reverse("pikau:pikau_unit", kwargs=kwargs)
+ response = self.client.get(url)
+ self.assertEqual(404, response.status_code)
+
+ def test_pikau_unit_view_context_with_previous_unit(self):
+ pikau_course = self.test_data.create_pikau_course(1)
+ pikau_unit_1 = self.test_data.create_pikau_unit(pikau_course, 1)
+ pikau_unit_2 = self.test_data.create_pikau_unit(pikau_course, 2)
+
+ kwargs = {
+ "course_slug": "pikau-course-1",
+ "unit_slug": "pikau-unit-2"
+ }
+ url = reverse("pikau:pikau_unit", kwargs=kwargs)
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ previous_unit = response.context["previous_unit"]
+ self.assertEqual(previous_unit, pikau_unit_1)
+
+ def test_pikau_unit_view_context_with_next_unit(self):
+ pikau_course = self.test_data.create_pikau_course(1)
+ pikau_unit_1 = self.test_data.create_pikau_unit(pikau_course, 1)
+ pikau_unit_2 = self.test_data.create_pikau_unit(pikau_course, 2)
+
+ kwargs = {
+ "course_slug": "pikau-course-1",
+ "unit_slug": "pikau-unit-1"
+ }
+ url = reverse("pikau:pikau_unit", kwargs=kwargs)
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ next_unit = response.context["next_unit"]
+ self.assertEqual(next_unit, pikau_unit_2)
+
+ def test_pikau_unit_view_context_with_previous_and_next_unit(self):
+ pikau_course = self.test_data.create_pikau_course(1)
+ pikau_unit_1 = self.test_data.create_pikau_unit(pikau_course, 1)
+ pikau_unit_2 = self.test_data.create_pikau_unit(pikau_course, 2)
+ pikau_unit_3 = self.test_data.create_pikau_unit(pikau_course, 3)
+
+ kwargs = {
+ "course_slug": "pikau-course-1",
+ "unit_slug": "pikau-unit-2"
+ }
+ url = reverse("pikau:pikau_unit", kwargs=kwargs)
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+
+ previous_unit = response.context["previous_unit"]
+ self.assertEqual(previous_unit, pikau_unit_1)
+ next_unit = response.context["next_unit"]
+ self.assertEqual(next_unit, pikau_unit_3)
+
+ def test_pikau_unit_view_context_with_no_previous_or_next_units(self):
+ pikau_course = self.test_data.create_pikau_course(1)
+ pikau_unit_1 = self.test_data.create_pikau_unit(pikau_course, 1)
+
+ kwargs = {
+ "course_slug": "pikau-course-1",
+ "unit_slug": "pikau-unit-1"
+ }
+ url = reverse("pikau:pikau_unit", kwargs=kwargs)
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+
+ previous_unit = response.context["previous_unit"]
+ self.assertEqual(previous_unit, None)
+ next_unit = response.context["next_unit"]
+ self.assertEqual(next_unit, None)
\ No newline at end of file
From 96460f24182bfecc7f1c149b8a7ff8b490d80d6e Mon Sep 17 00:00:00 2001
From: pyup-bot
Date: Thu, 31 May 2018 10:40:59 +1200
Subject: [PATCH 16/72] Update django-anymail from 2.2 to 3.0
---
requirements/base.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/requirements/base.txt b/requirements/base.txt
index fa4ccdc..2e402da 100644
--- a/requirements/base.txt
+++ b/requirements/base.txt
@@ -22,4 +22,4 @@ argon2-cffi==18.1.0
# Users
django-allauth==0.36.0
django-crispy-forms==1.7.2
-django-anymail==2.2
+django-anymail==3.0
From f5ce793772672b62f75c130c944a9dbd8e7fa966 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Thu, 31 May 2018 11:42:08 +1200
Subject: [PATCH 17/72] Add tests for pikau milestone view.
---
tests/pikau/views/test_milestone_view.py | 118 +++++++++++++++++++++++
1 file changed, 118 insertions(+)
create mode 100644 tests/pikau/views/test_milestone_view.py
diff --git a/tests/pikau/views/test_milestone_view.py b/tests/pikau/views/test_milestone_view.py
new file mode 100644
index 0000000..80b291b
--- /dev/null
+++ b/tests/pikau/views/test_milestone_view.py
@@ -0,0 +1,118 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+from django.urls import reverse
+from django.template import defaultfilters
+
+import datetime as dt
+from datetime import datetime
+
+class MilestoneViewTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.language = "en"
+ self.test_data = PikauTestDataGenerator()
+ self.current_time = datetime.now()
+
+ def test_pikau_milestone_list_view_with_no_milestones(self):
+ url = reverse("pikau:milestone_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["milestones"]), 0)
+
+ def test_pikau_milestone_list_view_with_one_milestone(self):
+ milestone = self.test_data.create_milestone(1, self.current_time)
+
+ url = reverse("pikau:milestone_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["milestones"]), 1)
+ self.assertQuerysetEqual(
+ response.context["milestones"],
+ ["".format(defaultfilters.date(self.current_time))]
+ )
+
+ def test_pikau_milestone_list_view_order(self):
+ date_1 = self.current_time
+ date_2 = self.current_time + dt.timedelta(days=30)
+ milestone_1 = self.test_data.create_milestone(1, date_2)
+ milestone_2 = self.test_data.create_milestone(2, date_1)
+
+ url = reverse("pikau:milestone_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertQuerysetEqual(
+ response.context["milestones"],
+ [
+ "".format(defaultfilters.date(date_1)),
+ "".format(defaultfilters.date(date_2))
+ ],
+ )
+
+ def test_pikau_milestone_list_view_with_two_milestones(self):
+ milestone = self.test_data.create_milestone(1, self.current_time)
+
+ url = reverse("pikau:milestone_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(len(response.context["milestones"]), 1)
+ self.assertQuerysetEqual(
+ response.context["milestones"],
+ ["".format(defaultfilters.date(self.current_time))]
+ )
+
+ def test_pikau_milestone_list_view_milestone_status_course_count(self):
+ # checks how many courses are on a certain status for a certain milestone
+ pikau_course = self.test_data.create_pikau_course(1)
+ milestone = self.test_data.create_milestone(1, self.current_time)
+ pikau_course.milestone = milestone
+ pikau_course.status = 3
+ pikau_course.save()
+
+ url = reverse("pikau:milestone_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+
+ milestones = response.context["milestones"]
+ milestone_1 = milestones[0]
+ milestone_1_status_3_course_count = milestone_1.status[3]
+ milestone_1_status_7_course_count = milestone_1.status[7]
+ self.assertEqual(milestone_1_status_3_course_count, 1)
+ self.assertEqual(milestone_1_status_7_course_count, 0)
+
+ def test_pikau_milestone_list_view_status_stages(self):
+ url = reverse("pikau:milestone_list")
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+
+ status_stages = [
+ (1, 'Stage 1', 'Conceptualising'),
+ (2, 'Stage 2', 'Developing'),
+ (3, 'Stage 3', 'Reviewing\nAcademic'),
+ (4, 'Stage 4', 'Reviewing\nLanguage'),
+ (5, 'Stage 5', 'Reviewing\nTechnical'),
+ (6, 'Stage 6', 'Completed'),
+ (7, 'Stage 7', 'Completed\nPublished to iQualify'),
+ ]
+ self.assertEqual(response.context["status_stages"], status_stages)
+
+ def test_milestone_view_no_milestones(self):
+ url = reverse("pikau:milestone", kwargs={"pk": 1})
+ response = self.client.get(url)
+ self.assertEqual(404, response.status_code)
+
+ def test_milestone_view_with_valid_pk(self):
+ milestone = self.test_data.create_milestone(1, self.current_time)
+ url = reverse("pikau:milestone", kwargs={"pk": 1})
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(
+ url,
+ "/pikau/milestones/1/"
+ )
+
+ def test_milestone_view_with_invalid_pk(self):
+ milestone = self.test_data.create_milestone(1, self.current_time)
+ url = reverse("pikau:milestone", kwargs={"pk": 5})
+ response = self.client.get(url)
+ self.assertEqual(404, response.status_code)
From 85eb13ee7a9cf49cb258d4db61de3b11dfb3fcda Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Thu, 31 May 2018 12:52:54 +1200
Subject: [PATCH 18/72] Add more tests for the pikau documentation view.
---
tests/pikau/views/test_documentation_view.py | 98 ++++++++++++++++++++
1 file changed, 98 insertions(+)
diff --git a/tests/pikau/views/test_documentation_view.py b/tests/pikau/views/test_documentation_view.py
index 9fb36af..7962c88 100644
--- a/tests/pikau/views/test_documentation_view.py
+++ b/tests/pikau/views/test_documentation_view.py
@@ -1,15 +1,113 @@
from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
from django.urls import reverse
from http import HTTPStatus
+from pikau.models import (
+ Level,
+ ProgressOutcome,
+ Topic,
+ Tag,
+ STATUS_CHOICES,
+ READINESS_LEVELS,
+)
+
class DocumentationViewTest(BaseTestWithDB):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
+ self.test_data = PikauTestDataGenerator()
self.language = "en"
def test_documentation_view(self):
response = self.client.get(reverse("pikau:docs"))
self.assertEqual(HTTPStatus.OK, response.status_code)
self.assertContains(response, "Pīkau Documentation")
+
+ def test_documentation_view_context_status_stages(self):
+ response = self.client.get(reverse("pikau:docs"))
+ self.assertEqual(HTTPStatus.OK, response.status_code)
+ self.assertEqual(response.context["status_stages"], STATUS_CHOICES)
+
+ def test_documentation_view_context_topics(self):
+ topic_1 = self.test_data.create_topic(1)
+ topic_2 = self.test_data.create_topic(2)
+
+ response = self.client.get(reverse("pikau:docs"))
+ self.assertEqual(HTTPStatus.OK, response.status_code)
+ self.assertQuerysetEqual(
+ response.context["topics"],
+ [
+ "",
+ "",
+ ]
+ )
+
+ def test_documentation_view_context_levels(self):
+ level_1 = self.test_data.create_level(1)
+ level_2 = self.test_data.create_level(2)
+
+ response = self.client.get(reverse("pikau:docs"))
+ self.assertEqual(HTTPStatus.OK, response.status_code)
+ self.assertQuerysetEqual(
+ response.context["levels"],
+ [
+ "",
+ "",
+ ]
+ )
+
+ def test_documentation_view_context_progress_outcomes(self):
+ progress_outcome_1 = self.test_data.create_progress_outcome(1)
+ progress_outcome_2 = self.test_data.create_progress_outcome(2)
+
+ response = self.client.get(reverse("pikau:docs"))
+ self.assertEqual(HTTPStatus.OK, response.status_code)
+ self.assertQuerysetEqual(
+ ProgressOutcome.objects.all(),
+ [
+ "",
+ "",
+ ],
+ ordered=False
+ )
+
+ def test_documentation_view_context_srt_tags(self):
+ tag_1 = Tag(
+ slug="srt-tag-1",
+ name="srt-tag-1-name",
+ description="Description for tag 1.
",
+ )
+ tag_1.save()
+
+ tag_2 = Tag(
+ slug="srt-tag-2",
+ name="srt-tag-2-name",
+ description="Description for tag 2.
",
+ )
+ tag_2.save()
+
+ response = self.client.get(reverse("pikau:docs"))
+ self.assertEqual(HTTPStatus.OK, response.status_code)
+ self.assertQuerysetEqual(
+ response.context["srt_tags"],
+ [
+ "",
+ "",
+ ]
+ )
+
+ def test_documentation_view_context_readiness_levels(self):
+ response = self.client.get(reverse("pikau:docs"))
+ self.assertEqual(HTTPStatus.OK, response.status_code)
+ self.assertEqual(response.context["readiness_levels"], READINESS_LEVELS)
+
+ def test_documentation_view_with_no_data(self):
+ response = self.client.get(reverse("pikau:docs"))
+ self.assertEqual(HTTPStatus.OK, response.status_code)
+ self.assertEqual(response.context["status_stages"], STATUS_CHOICES)
+ self.assertQuerysetEqual(response.context["topics"], [])
+ self.assertQuerysetEqual(response.context["levels"], [])
+ self.assertQuerysetEqual(response.context["progress_outcomes"], [])
+ self.assertEqual(response.context["readiness_levels"], READINESS_LEVELS)
\ No newline at end of file
From 89b55c0c3694b135e95a06dd270de3c458368099 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Fri, 1 Jun 2018 11:02:22 +1200
Subject: [PATCH 19/72] Add more tests to test file model.
---
tests/files/models/test_file.py | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/tests/files/models/test_file.py b/tests/files/models/test_file.py
index 48981b6..c6c18ee 100644
--- a/tests/files/models/test_file.py
+++ b/tests/files/models/test_file.py
@@ -1,6 +1,8 @@
from tests.BaseTestWithDB import BaseTestWithDB
from tests.files.FileTestDataGenerator import FileTestDataGenerator
+from files.models import File
+from django.db import IntegrityError
class FileModelTest(BaseTestWithDB):
@@ -14,3 +16,27 @@ def test_file_str(self):
obj.__str__(),
"File 1"
)
+
+ def test_file_model_one_file(self):
+ file = self.test_data.create_file(1)
+ query_result = File.objects.get(slug="file-1")
+ self.assertEqual(query_result, file)
+
+ def test_file_model_two_files(self):
+ file_1 = self.test_data.create_file(1)
+ file_2 = self.test_data.create_file(2)
+ self.assertQuerysetEqual(
+ File.objects.all(),
+ [
+ "File: file-1",
+ "File: file-2"
+ ],
+ ordered=False
+ )
+
+ def test_file_model_uniqueness(self):
+ file = self.test_data.create_file(1)
+ self.assertRaises(
+ IntegrityError,
+ lambda: self.test_data.create_file(1)
+ )
From 169b255a1761bf22c0a5ce93bee1796428f43917 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Fri, 1 Jun 2018 11:10:58 +1200
Subject: [PATCH 20/72] Test repr function in file model.
---
tests/files/models/test_file.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/files/models/test_file.py b/tests/files/models/test_file.py
index c6c18ee..f904e42 100644
--- a/tests/files/models/test_file.py
+++ b/tests/files/models/test_file.py
@@ -16,6 +16,12 @@ def test_file_str(self):
obj.__str__(),
"File 1"
)
+ def test_file_repr(self):
+ obj = self.test_data.create_file(1)
+ self.assertEqual(
+ obj.__repr__(),
+ "File: {}".format(obj.slug)
+ )
def test_file_model_one_file(self):
file = self.test_data.create_file(1)
From 16abd8a47916db3b46b324f12545620671a471d3 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Fri, 1 Jun 2018 11:15:29 +1200
Subject: [PATCH 21/72] Formatting.
---
tests/files/models/test_file.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/files/models/test_file.py b/tests/files/models/test_file.py
index f904e42..5e1e45c 100644
--- a/tests/files/models/test_file.py
+++ b/tests/files/models/test_file.py
@@ -16,6 +16,7 @@ def test_file_str(self):
obj.__str__(),
"File 1"
)
+
def test_file_repr(self):
obj = self.test_data.create_file(1)
self.assertEqual(
From f127267d3bc6386ceedfe460a30d395eaf76bfac Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Fri, 1 Jun 2018 11:41:41 +1200
Subject: [PATCH 22/72] Add TODO statement for progress outcome view tests.
---
.../pikau/views/test_progress_outcome_view.py | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 tests/pikau/views/test_progress_outcome_view.py
diff --git a/tests/pikau/views/test_progress_outcome_view.py b/tests/pikau/views/test_progress_outcome_view.py
new file mode 100644
index 0000000..5f4bfeb
--- /dev/null
+++ b/tests/pikau/views/test_progress_outcome_view.py
@@ -0,0 +1,37 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
+from django.urls import reverse
+
+
+class ProgressOutcomeViewTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.language = "en"
+ self.test_data = PikauTestDataGenerator()
+
+ def test_pikau_progress_outcome_view_with_valid_slug(self):
+ progress_outcome = self.test_data.create_progress_outcome(1)
+
+ kwargs = {
+ "slug": "progress-outcome-1",
+ }
+ url = reverse("pikau:progress_outcome", kwargs=kwargs)
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(
+ url,
+ "/pikau/progress-outcomes/progress-outcome-1/"
+ )
+
+ def test_pikau_progress_outcome_view_with_invalid_slug(self):
+ progress_outcome = self.test_data.create_progress_outcome(1)
+
+ kwargs = {
+ "slug": "progress-outcome-5",
+ }
+ url = reverse("pikau:progress_outcome", kwargs=kwargs)
+ response = self.client.get(url)
+ self.assertEqual(404, response.status_code)
+
+ # TODO: Add tests for heatmap.
\ No newline at end of file
From a3cc089115ca76260ef2657cdc2d69c6fe96d8df Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Fri, 1 Jun 2018 11:45:27 +1200
Subject: [PATCH 23/72] Add tests for file licence model view.
---
tests/files/models/test_licence_model.py | 55 ++++++++++++++++++++++++
1 file changed, 55 insertions(+)
create mode 100644 tests/files/models/test_licence_model.py
diff --git a/tests/files/models/test_licence_model.py b/tests/files/models/test_licence_model.py
new file mode 100644
index 0000000..cfa9a1c
--- /dev/null
+++ b/tests/files/models/test_licence_model.py
@@ -0,0 +1,55 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from tests.files.FileTestDataGenerator import FileTestDataGenerator
+
+from files.models import Licence
+from django.db import IntegrityError
+
+class LicenceModelTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.test_data = FileTestDataGenerator()
+
+ def test_licence_str(self):
+ obj = self.test_data.create_licence(1)
+ self.assertEqual(
+ obj.__str__(),
+ "Licence 1"
+ )
+
+ def test_licence_model_one_licence(self):
+ licence = self.test_data.create_licence(1)
+ query_result = Licence.objects.get(name="Licence 1")
+ self.assertEqual(query_result, licence)
+
+ def test_licence_model_two_licences(self):
+ licence_1 = self.test_data.create_licence(1)
+ licence_2 = self.test_data.create_licence(2)
+ self.assertQuerysetEqual(
+ Licence.objects.all(),
+ [
+ "",
+ "",
+ ],
+ ordered=False
+ )
+
+ def test_licence_model_uniqueness(self):
+ licence = self.test_data.create_licence(1)
+ self.assertRaises(
+ IntegrityError,
+ lambda: self.test_data.create_licence(1)
+ )
+
+ def test_licence_model_ordering(self):
+ licence_3 = self.test_data.create_licence(3)
+ licence_1 = self.test_data.create_licence(1)
+ licence_2 = self.test_data.create_licence(2)
+ self.assertQuerysetEqual(
+ Licence.objects.all(),
+ [
+ "",
+ "",
+ "",
+ ],
+ )
\ No newline at end of file
From 83e278c7bca0eb5671c750a8307127c6a407b919 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Fri, 1 Jun 2018 12:34:42 +1200
Subject: [PATCH 24/72] Add tests for pikau pathways view.
---
tests/pikau/views/test_pathways_view.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 tests/pikau/views/test_pathways_view.py
diff --git a/tests/pikau/views/test_pathways_view.py b/tests/pikau/views/test_pathways_view.py
new file mode 100644
index 0000000..4237808
--- /dev/null
+++ b/tests/pikau/views/test_pathways_view.py
@@ -0,0 +1,21 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from django.urls import reverse
+
+from pikau.models import READINESS_LEVELS
+
+class PathwaysViewTest(BaseTestWithDB):
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.language = "en"
+
+ def test_pathways_view(self):
+ response = self.client.get(reverse("pikau:pathways"))
+ self.assertEqual(200, response.status_code)
+
+ def test_pathways_view_context_readiness_levels(self):
+ response = self.client.get(reverse("pikau:pathways"))
+ self.assertEqual(200, response.status_code)
+ self.assertEqual(response.context["readiness_levels"], READINESS_LEVELS)
+
+ # TODO: test pathways notation - utils test.
\ No newline at end of file
From 2f6ddbb977a71f3e84e6003e8289275cb6fa58a5 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Fri, 1 Jun 2018 13:17:51 +1200
Subject: [PATCH 25/72] Tidy up.
---
tests/pikau/PikauTestDataGenerator.py | 1 -
tests/pikau/models/test_glossary_model.py | 2 +-
tests/pikau/models/test_goal_model.py | 2 +-
tests/pikau/models/test_level_model.py | 2 +-
tests/pikau/models/test_milestone_model.py | 5 +++--
tests/pikau/models/test_pikau_course.py | 1 +
tests/pikau/models/test_pikau_unit_model.py | 8 ++++----
tests/pikau/models/test_progress_outcome_model.py | 2 +-
tests/pikau/models/test_tag_model.py | 4 ++--
tests/pikau/models/test_topic_model.py | 2 +-
tests/pikau/views/test_glossary_view.py | 13 +++++--------
tests/pikau/views/test_goal_view.py | 10 ++--------
tests/pikau/views/test_level_view.py | 10 +---------
tests/pikau/views/test_milestone_view.py | 3 ++-
tests/pikau/views/test_pathways_view.py | 1 +
tests/pikau/views/test_pikau_course_view.py | 7 -------
tests/pikau/views/test_readiness_level_view.py | 2 +-
tests/pikau/views/test_tag_view.py | 10 +---------
tests/pikau/views/test_topic_view.py | 10 +---------
19 files changed, 29 insertions(+), 66 deletions(-)
diff --git a/tests/pikau/PikauTestDataGenerator.py b/tests/pikau/PikauTestDataGenerator.py
index ab2b4f1..159a718 100644
--- a/tests/pikau/PikauTestDataGenerator.py
+++ b/tests/pikau/PikauTestDataGenerator.py
@@ -184,7 +184,6 @@ def create_pikau_unit(self, pikau_course, number, module_name=False):
number=number,
pikau_course=pikau_course,
name="pikau-unit-{}-name".format(number),
- # module_name="pikau-unit-{}-module-name".format(number),
content="Content for piaku unit {}.
".format(number),
)
if module_name:
diff --git a/tests/pikau/models/test_glossary_model.py b/tests/pikau/models/test_glossary_model.py
index 7f8f5c4..a0af797 100644
--- a/tests/pikau/models/test_glossary_model.py
+++ b/tests/pikau/models/test_glossary_model.py
@@ -2,9 +2,9 @@
from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
from pikau.models import GlossaryTerm
-
from django.db import IntegrityError
+
class GlossaryModelTest(BaseTestWithDB):
def __init__(self, *args, **kwargs):
diff --git a/tests/pikau/models/test_goal_model.py b/tests/pikau/models/test_goal_model.py
index aca6e46..314f903 100644
--- a/tests/pikau/models/test_goal_model.py
+++ b/tests/pikau/models/test_goal_model.py
@@ -2,9 +2,9 @@
from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
from pikau.models import Goal
-
from django.db import IntegrityError
+
class GoalModelTest(BaseTestWithDB):
def __init__(self, *args, **kwargs):
diff --git a/tests/pikau/models/test_level_model.py b/tests/pikau/models/test_level_model.py
index 1f663f5..053438a 100644
--- a/tests/pikau/models/test_level_model.py
+++ b/tests/pikau/models/test_level_model.py
@@ -2,9 +2,9 @@
from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
from pikau.models import Level
-
from django.db import IntegrityError
+
class LevelModelTest(BaseTestWithDB):
def __init__(self, *args, **kwargs):
diff --git a/tests/pikau/models/test_milestone_model.py b/tests/pikau/models/test_milestone_model.py
index 5a04d04..0534ff7 100644
--- a/tests/pikau/models/test_milestone_model.py
+++ b/tests/pikau/models/test_milestone_model.py
@@ -9,6 +9,7 @@
import datetime as dt
from datetime import datetime
+
class MilestoneModelTest(BaseTestWithDB):
def __init__(self, *args, **kwargs):
@@ -30,7 +31,7 @@ def test_milestone_model_two_milestones(self):
Milestone.objects.all(),
[
"".format(defaultfilters.date(date_1)),
- "".format(defaultfilters.date(date_2))
+ "".format(defaultfilters.date(date_2)),
],
ordered=False
)
@@ -70,6 +71,6 @@ def test_milestone_model_ordering(self):
Milestone.objects.all(),
[
"".format(defaultfilters.date(date_1)),
- "".format(defaultfilters.date(date_2))
+ "".format(defaultfilters.date(date_2)),
],
)
diff --git a/tests/pikau/models/test_pikau_course.py b/tests/pikau/models/test_pikau_course.py
index e0815fc..8da9cc5 100644
--- a/tests/pikau/models/test_pikau_course.py
+++ b/tests/pikau/models/test_pikau_course.py
@@ -4,6 +4,7 @@
import datetime as dt
from datetime import datetime
+
class PikauCourseModelTest(BaseTestWithDB):
def __init__(self, *args, **kwargs):
diff --git a/tests/pikau/models/test_pikau_unit_model.py b/tests/pikau/models/test_pikau_unit_model.py
index ace5131..3a37a80 100644
--- a/tests/pikau/models/test_pikau_unit_model.py
+++ b/tests/pikau/models/test_pikau_unit_model.py
@@ -2,9 +2,9 @@
from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
from pikau.models import PikauUnit
-
from django.db import IntegrityError
+
class PikauUnitModelTest(BaseTestWithDB):
def __init__(self, *args, **kwargs):
@@ -25,7 +25,7 @@ def test_pikau_unit_model_two_units_with_module_name(self):
PikauUnit.objects.all(),
[
"",
- ""
+ "",
],
ordered=False
)
@@ -38,7 +38,7 @@ def test_pikau_unit_model_two_units_without_module_name(self):
PikauUnit.objects.all(),
[
"",
- ""
+ "",
],
ordered=False
)
@@ -77,6 +77,6 @@ def test_pikau_unit_model_ordering(self):
[
"",
"",
- ""
+ "",
]
)
diff --git a/tests/pikau/models/test_progress_outcome_model.py b/tests/pikau/models/test_progress_outcome_model.py
index 0c4fec3..139511a 100644
--- a/tests/pikau/models/test_progress_outcome_model.py
+++ b/tests/pikau/models/test_progress_outcome_model.py
@@ -2,9 +2,9 @@
from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
from pikau.models import ProgressOutcome
-
from django.db import IntegrityError
+
class ProgressOutcomeModelTest(BaseTestWithDB):
def __init__(self, *args, **kwargs):
diff --git a/tests/pikau/models/test_tag_model.py b/tests/pikau/models/test_tag_model.py
index f460659..8837e79 100644
--- a/tests/pikau/models/test_tag_model.py
+++ b/tests/pikau/models/test_tag_model.py
@@ -2,9 +2,9 @@
from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
from pikau.models import Tag
-
from django.db import IntegrityError
+
class TagModelTest(BaseTestWithDB):
def __init__(self, *args, **kwargs):
@@ -23,7 +23,7 @@ def test_tag_model_two_tags(self):
Tag.objects.all(),
[
"",
- ""
+ "",
],
ordered=False
)
diff --git a/tests/pikau/models/test_topic_model.py b/tests/pikau/models/test_topic_model.py
index eb94deb..5495c74 100644
--- a/tests/pikau/models/test_topic_model.py
+++ b/tests/pikau/models/test_topic_model.py
@@ -2,9 +2,9 @@
from tests.pikau.PikauTestDataGenerator import PikauTestDataGenerator
from pikau.models import Topic
-
from django.db import IntegrityError
+
class TopicModelTest(BaseTestWithDB):
def __init__(self, *args, **kwargs):
diff --git a/tests/pikau/views/test_glossary_view.py b/tests/pikau/views/test_glossary_view.py
index 874d7a1..77c9854 100644
--- a/tests/pikau/views/test_glossary_view.py
+++ b/tests/pikau/views/test_glossary_view.py
@@ -18,7 +18,6 @@ def test_pikau_glossary_view_with_no_definitions(self):
def test_pikau_glossary_view_with_one_definition(self):
term = self.test_data.create_glossary_term(1)
- term.save()
url = reverse("pikau:glossary")
response = self.client.get(url)
@@ -31,9 +30,7 @@ def test_pikau_glossary_view_with_one_definition(self):
def test_pikau_glossary_view_with_two_definitions(self):
term_1 = self.test_data.create_glossary_term(1)
- term_1.save()
term_2 = self.test_data.create_glossary_term(2)
- term_2.save()
url = reverse("pikau:glossary")
response = self.client.get(url)
@@ -41,16 +38,16 @@ def test_pikau_glossary_view_with_two_definitions(self):
self.assertEqual(len(response.context["glossary_terms"]), 2)
self.assertQuerysetEqual(
response.context["glossary_terms"],
- ["", ""]
+ [
+ "",
+ "",
+ ]
)
def test_pikau_glossary_view_order(self):
term_3 = self.test_data.create_glossary_term(3)
- term_3.save()
term_2 = self.test_data.create_glossary_term(2)
- term_2.save()
term_1 = self.test_data.create_glossary_term(1)
- term_1.save()
url = reverse("pikau:glossary")
response = self.client.get(url)
@@ -61,6 +58,6 @@ def test_pikau_glossary_view_order(self):
[
"",
"",
- ""
+ "",
]
)
diff --git a/tests/pikau/views/test_goal_view.py b/tests/pikau/views/test_goal_view.py
index ff3c665..adcc1d3 100644
--- a/tests/pikau/views/test_goal_view.py
+++ b/tests/pikau/views/test_goal_view.py
@@ -18,7 +18,6 @@ def test_pikau_goal_view_with_no_goals(self):
def test_pikau_goal_view_with_one_goal(self):
goal = self.test_data.create_goal(1)
- goal.save()
url = reverse("pikau:goal_list")
response = self.client.get(url)
@@ -31,9 +30,7 @@ def test_pikau_goal_view_with_one_goal(self):
def test_pikau_goal_view_with_two_goals(self):
goal_1 = self.test_data.create_goal(1)
- goal_1.save()
goal_2 = self.test_data.create_goal(2)
- goal_2.save()
url = reverse("pikau:goal_list")
response = self.client.get(url)
@@ -43,17 +40,14 @@ def test_pikau_goal_view_with_two_goals(self):
response.context["goals"],
[
"Description for goal 1.>",
- "Description for goal 2.>"
+ "Description for goal 2.>",
]
)
def test_pikau_goal_view_order(self):
goal_3 = self.test_data.create_goal(3)
- goal_3.save()
goal_2 = self.test_data.create_goal(2)
- goal_2.save()
goal_1 = self.test_data.create_goal(1)
- goal_1.save()
url = reverse("pikau:goal_list")
response = self.client.get(url)
@@ -64,6 +58,6 @@ def test_pikau_goal_view_order(self):
[
"Description for goal 1.>",
"Description for goal 2.>",
- "Description for goal 3.>"
+ "Description for goal 3.>",
]
)
\ No newline at end of file
diff --git a/tests/pikau/views/test_level_view.py b/tests/pikau/views/test_level_view.py
index 5ad2eae..d9ea7f8 100644
--- a/tests/pikau/views/test_level_view.py
+++ b/tests/pikau/views/test_level_view.py
@@ -12,7 +12,6 @@ def __init__(self, *args, **kwargs):
def test_pikau_level_view_with_valid_slug(self):
level = self.test_data.create_level(1)
- level.save()
url = reverse("pikau:level", kwargs={"slug": "level-1"})
response = self.client.get(url)
@@ -21,7 +20,6 @@ def test_pikau_level_view_with_valid_slug(self):
def test_pikau_level_view_with_invalid_slug(self):
level = self.test_data.create_level(1)
- level.save()
url = reverse("pikau:level", kwargs={"slug": "level-5"})
response = self.client.get(url)
@@ -35,7 +33,6 @@ def test_pikau_level_list_view_with_no_levels(self):
def test_pikau_level_list_view_with_one_level(self):
level = self.test_data.create_level(1)
- level.save()
url = reverse("pikau:level_list")
response = self.client.get(url)
@@ -48,9 +45,7 @@ def test_pikau_level_list_view_with_one_level(self):
def test_pikau_level_list_view_with_two_levels(self):
level_1 = self.test_data.create_level(1)
- level_1.save()
level_2 = self.test_data.create_level(2)
- level_2.save()
url = reverse("pikau:level_list")
response = self.client.get(url)
@@ -66,11 +61,8 @@ def test_pikau_level_list_view_with_two_levels(self):
def test_pikau_level_list_view_order(self):
level_3 = self.test_data.create_level(3)
- level_3.save()
level_2 = self.test_data.create_level(2)
- level_2.save()
level_1 = self.test_data.create_level(1)
- level_1.save()
url = reverse("pikau:level_list")
response = self.client.get(url)
@@ -81,6 +73,6 @@ def test_pikau_level_list_view_order(self):
[
"",
"",
- ""
+ "",
]
)
\ No newline at end of file
diff --git a/tests/pikau/views/test_milestone_view.py b/tests/pikau/views/test_milestone_view.py
index 80b291b..fe1ba9b 100644
--- a/tests/pikau/views/test_milestone_view.py
+++ b/tests/pikau/views/test_milestone_view.py
@@ -6,6 +6,7 @@
import datetime as dt
from datetime import datetime
+
class MilestoneViewTest(BaseTestWithDB):
def __init__(self, *args, **kwargs):
@@ -45,7 +46,7 @@ def test_pikau_milestone_list_view_order(self):
response.context["milestones"],
[
"".format(defaultfilters.date(date_1)),
- "".format(defaultfilters.date(date_2))
+ "".format(defaultfilters.date(date_2)),
],
)
diff --git a/tests/pikau/views/test_pathways_view.py b/tests/pikau/views/test_pathways_view.py
index 4237808..9f1cdad 100644
--- a/tests/pikau/views/test_pathways_view.py
+++ b/tests/pikau/views/test_pathways_view.py
@@ -3,6 +3,7 @@
from pikau.models import READINESS_LEVELS
+
class PathwaysViewTest(BaseTestWithDB):
def __init__(self, *args, **kwargs):
diff --git a/tests/pikau/views/test_pikau_course_view.py b/tests/pikau/views/test_pikau_course_view.py
index ed84989..7bcbf5d 100644
--- a/tests/pikau/views/test_pikau_course_view.py
+++ b/tests/pikau/views/test_pikau_course_view.py
@@ -18,7 +18,6 @@ def test_pikau_course_list_view_with_no_courses(self):
def test_pikau_course_list_view_with_one_course(self):
pikau_course = self.test_data.create_pikau_course(1)
- pikau_course.save()
url = reverse("pikau:pikau_course_list")
response = self.client.get(url)
@@ -31,9 +30,7 @@ def test_pikau_course_list_view_with_one_course(self):
def test_pikau_course_list_view_with_two_courses(self):
pikau_course_1 = self.test_data.create_pikau_course(1)
- pikau_course_1.save()
pikau_course_2 = self.test_data.create_pikau_course(2)
- pikau_course_2.save()
url = reverse("pikau:pikau_course_list")
response = self.client.get(url)
@@ -49,7 +46,6 @@ def test_pikau_course_list_view_with_two_courses(self):
def test_pikau_course_view_with_valid_slug(self):
pikau_course_1 = self.test_data.create_pikau_course(1)
- pikau_course_1.save()
url = reverse("pikau:pikau_course", kwargs={"slug": "pikau-course-1"})
response = self.client.get(url)
@@ -58,7 +54,6 @@ def test_pikau_course_view_with_valid_slug(self):
def test_pikau_course_view_with_invalid_slug(self):
pikau_course_1 = self.test_data.create_pikau_course(1)
- pikau_course_1.save()
url = reverse("pikau:pikau_course", kwargs={"slug": "pikau-course-5"})
response = self.client.get(url)
@@ -66,7 +61,6 @@ def test_pikau_course_view_with_invalid_slug(self):
def test_pikau_course_content_view_with_valid_slug(self):
pikau_course_1 = self.test_data.create_pikau_course(1)
- pikau_course_1.save()
url = reverse("pikau:pikau_content", kwargs={"slug": "pikau-course-1"})
response = self.client.get(url)
@@ -75,7 +69,6 @@ def test_pikau_course_content_view_with_valid_slug(self):
def test_pikau_course_content_view_with_invalid_slug(self):
pikau_course_1 = self.test_data.create_pikau_course(1)
- pikau_course_1.save()
url = reverse("pikau:pikau_content", kwargs={"slug": "pikau-course-5"})
response = self.client.get(url)
diff --git a/tests/pikau/views/test_readiness_level_view.py b/tests/pikau/views/test_readiness_level_view.py
index ee0f910..1a6694b 100644
--- a/tests/pikau/views/test_readiness_level_view.py
+++ b/tests/pikau/views/test_readiness_level_view.py
@@ -137,7 +137,7 @@ def test_readiness_level_view_two_courses(self):
pikau_courses,
[
"",
- ""
+ "",
],
ordered=False
)
diff --git a/tests/pikau/views/test_tag_view.py b/tests/pikau/views/test_tag_view.py
index 7ea0628..9e1d06a 100644
--- a/tests/pikau/views/test_tag_view.py
+++ b/tests/pikau/views/test_tag_view.py
@@ -12,7 +12,6 @@ def __init__(self, *args, **kwargs):
def test_pikau_tag_view_with_valid_slug(self):
tag = self.test_data.create_tag(1)
- tag.save()
url = reverse("pikau:tag", kwargs={"slug": "tag-1"})
response = self.client.get(url)
@@ -21,7 +20,6 @@ def test_pikau_tag_view_with_valid_slug(self):
def test_pikau_tag_view_with_invalid_slug(self):
tag = self.test_data.create_tag(1)
- tag.save()
url = reverse("pikau:tag", kwargs={"slug": "tag-5"})
response = self.client.get(url)
@@ -35,7 +33,6 @@ def test_pikau_tag_list_view_with_no_tags(self):
def test_pikau_tag_list_view_with_one_tag(self):
tag = self.test_data.create_tag(1)
- tag.save()
url = reverse("pikau:tag_list")
response = self.client.get(url)
@@ -48,9 +45,7 @@ def test_pikau_tag_list_view_with_one_tag(self):
def test_pikau_tag_list_view_with_two_tags(self):
tag_1 = self.test_data.create_tag(1)
- tag_1.save()
tag_2 = self.test_data.create_tag(2)
- tag_2.save()
url = reverse("pikau:tag_list")
response = self.client.get(url)
@@ -66,11 +61,8 @@ def test_pikau_tag_list_view_with_two_tags(self):
def test_pikau_tag_list_view_order(self):
tag_3 = self.test_data.create_tag(3)
- tag_3.save()
tag_2 = self.test_data.create_tag(2)
- tag_2.save()
tag_1 = self.test_data.create_tag(1)
- tag_1.save()
url = reverse("pikau:tag_list")
response = self.client.get(url)
@@ -81,6 +73,6 @@ def test_pikau_tag_list_view_order(self):
[
"",
"",
- ""
+ "",
]
)
\ No newline at end of file
diff --git a/tests/pikau/views/test_topic_view.py b/tests/pikau/views/test_topic_view.py
index 9f60b8a..ee518bd 100644
--- a/tests/pikau/views/test_topic_view.py
+++ b/tests/pikau/views/test_topic_view.py
@@ -12,7 +12,6 @@ def __init__(self, *args, **kwargs):
def test_pikau_topic_view_with_valid_slug(self):
topic = self.test_data.create_topic(1)
- topic.save()
url = reverse("pikau:topic", kwargs={"slug": "topic-1"})
response = self.client.get(url)
@@ -21,7 +20,6 @@ def test_pikau_topic_view_with_valid_slug(self):
def test_pikau_topic_view_with_invalid_slug(self):
topic = self.test_data.create_topic(1)
- topic.save()
url = reverse("pikau:topic", kwargs={"slug": "topic-5"})
response = self.client.get(url)
@@ -35,7 +33,6 @@ def test_pikau_topic_list_view_with_no_topics(self):
def test_pikau_topic_list_view_with_one_topic(self):
topic = self.test_data.create_topic(1)
- topic.save()
url = reverse("pikau:topic_list")
response = self.client.get(url)
@@ -48,9 +45,7 @@ def test_pikau_topic_list_view_with_one_topic(self):
def test_pikau_topic_list_view_with_two_topics(self):
topic_1 = self.test_data.create_topic(1)
- topic_1.save()
topic_2 = self.test_data.create_topic(2)
- topic_2.save()
url = reverse("pikau:topic_list")
response = self.client.get(url)
@@ -67,11 +62,8 @@ def test_pikau_topic_list_view_with_two_topics(self):
def test_pikau_topic_list_view_order(self):
topic_3 = self.test_data.create_topic(3)
- topic_3.save()
topic_2 = self.test_data.create_topic(2)
- topic_2.save()
topic_1 = self.test_data.create_topic(1)
- topic_1.save()
url = reverse("pikau:topic_list")
response = self.client.get(url)
@@ -82,6 +74,6 @@ def test_pikau_topic_list_view_order(self):
[
"",
"",
- ""
+ "",
]
)
\ No newline at end of file
From 5c2aac26e802a529c9e6e3266f6704d0186900a4 Mon Sep 17 00:00:00 2001
From: pyup-bot
Date: Sat, 2 Jun 2018 12:51:02 +1200
Subject: [PATCH 26/72] Update django from 2.0.5 to 2.0.6
---
requirements/base.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/requirements/base.txt b/requirements/base.txt
index fa4ccdc..3c7f432 100644
--- a/requirements/base.txt
+++ b/requirements/base.txt
@@ -1,7 +1,7 @@
# Base dependencies go here
# Django
-django==2.0.5
+django==2.0.6
whitenoise==3.3.1
django-heroku==0.3.1
django-environ==0.4.4
From 6568d8493314f2bc238f01854c1841f241f7ae39 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 10:30:43 +1200
Subject: [PATCH 27/72] Update tests to reflect changes to views from a merge.
---
tests/pikau/PikauTestDataGenerator.py | 2 +-
tests/pikau/views/test_glossary_view.py | 30 ++++++++++++++-----------
tests/pikau/views/test_topic_view.py | 2 +-
3 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/tests/pikau/PikauTestDataGenerator.py b/tests/pikau/PikauTestDataGenerator.py
index 159a718..2cf7f9a 100644
--- a/tests/pikau/PikauTestDataGenerator.py
+++ b/tests/pikau/PikauTestDataGenerator.py
@@ -65,7 +65,7 @@ def create_glossary_term(self, number):
glossary_term = GlossaryTerm(
slug="glossary-term-{}".format(number),
term="Glossary Term {}".format(number),
- description="Description for glossary term {}.
".format(number),
+ definition="Description for glossary term {}.
".format(number),
)
glossary_term.save()
return glossary_term
diff --git a/tests/pikau/views/test_glossary_view.py b/tests/pikau/views/test_glossary_view.py
index 77c9854..7a15a4e 100644
--- a/tests/pikau/views/test_glossary_view.py
+++ b/tests/pikau/views/test_glossary_view.py
@@ -11,20 +11,20 @@ def __init__(self, *args, **kwargs):
self.test_data = PikauTestDataGenerator()
def test_pikau_glossary_view_with_no_definitions(self):
- url = reverse("pikau:glossary")
+ url = reverse("pikau:glossaryterm_list")
response = self.client.get(url)
self.assertEqual(200, response.status_code)
- self.assertEqual(len(response.context["glossary_terms"]), 0)
+ self.assertEqual(len(response.context["glossaryterm_list"]), 0)
def test_pikau_glossary_view_with_one_definition(self):
term = self.test_data.create_glossary_term(1)
- url = reverse("pikau:glossary")
+ url = reverse("pikau:glossaryterm_list")
response = self.client.get(url)
self.assertEqual(200, response.status_code)
- self.assertEqual(len(response.context["glossary_terms"]), 1)
+ self.assertEqual(len(response.context["glossaryterm_list"]), 1)
self.assertQuerysetEqual(
- response.context["glossary_terms"],
+ response.context["glossaryterm_list"],
[""]
)
@@ -32,16 +32,17 @@ def test_pikau_glossary_view_with_two_definitions(self):
term_1 = self.test_data.create_glossary_term(1)
term_2 = self.test_data.create_glossary_term(2)
- url = reverse("pikau:glossary")
+ url = reverse("pikau:glossaryterm_list")
response = self.client.get(url)
self.assertEqual(200, response.status_code)
- self.assertEqual(len(response.context["glossary_terms"]), 2)
+ self.assertEqual(len(response.context["glossaryterm_list"]), 2)
self.assertQuerysetEqual(
- response.context["glossary_terms"],
+ response.context["glossaryterm_list"],
[
"",
"",
- ]
+ ],
+ ordered=False
)
def test_pikau_glossary_view_order(self):
@@ -49,15 +50,18 @@ def test_pikau_glossary_view_order(self):
term_2 = self.test_data.create_glossary_term(2)
term_1 = self.test_data.create_glossary_term(1)
- url = reverse("pikau:glossary")
+ url = reverse("pikau:glossaryterm_list")
response = self.client.get(url)
self.assertEqual(200, response.status_code)
- self.assertEqual(len(response.context["glossary_terms"]), 3)
+ self.assertEqual(len(response.context["glossaryterm_list"]), 3)
self.assertQuerysetEqual(
- response.context["glossary_terms"],
+ response.context["glossaryterm_list"],
[
"",
"",
"",
- ]
+ ],
+ ordered=False
)
+
+ # TODO: Test remaining glossary related views.
diff --git a/tests/pikau/views/test_topic_view.py b/tests/pikau/views/test_topic_view.py
index ee518bd..8ba3d0f 100644
--- a/tests/pikau/views/test_topic_view.py
+++ b/tests/pikau/views/test_topic_view.py
@@ -16,7 +16,7 @@ def test_pikau_topic_view_with_valid_slug(self):
url = reverse("pikau:topic", kwargs={"slug": "topic-1"})
response = self.client.get(url)
self.assertEqual(200, response.status_code)
- self.assertEqual(url, "/pikau/topics/topic-1/")
+ self.assertEqual(url, "/pikau/topics/view/topic-1/")
def test_pikau_topic_view_with_invalid_slug(self):
topic = self.test_data.create_topic(1)
From ba415732580d8b7183ac1e71858818e2726fc360 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 10:32:20 +1200
Subject: [PATCH 28/72] Pikau course content page will now load even if there
are no Pikau units under the course. Add a test for this.
---
templates/pikau/pikaucourse_content.html | 8 +++++---
tests/pikau/views/test_pikau_course_view.py | 9 +++++++++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/templates/pikau/pikaucourse_content.html b/templates/pikau/pikaucourse_content.html
index 88c9a42..d6ca2ac 100644
--- a/templates/pikau/pikaucourse_content.html
+++ b/templates/pikau/pikaucourse_content.html
@@ -30,9 +30,11 @@ {{ pikau_course.name }}
{% endif %}
-
- Start the course 🡢
-
+ {% if pikau_course.content.all %}
+
+ Start the course 🡢
+
+ {% endif %}
diff --git a/tests/pikau/views/test_pikau_course_view.py b/tests/pikau/views/test_pikau_course_view.py
index 7bcbf5d..39f69b9 100644
--- a/tests/pikau/views/test_pikau_course_view.py
+++ b/tests/pikau/views/test_pikau_course_view.py
@@ -61,6 +61,7 @@ def test_pikau_course_view_with_invalid_slug(self):
def test_pikau_course_content_view_with_valid_slug(self):
pikau_course_1 = self.test_data.create_pikau_course(1)
+ pikau_unit = self.test_data.create_pikau_unit(pikau_course_1, 1)
url = reverse("pikau:pikau_content", kwargs={"slug": "pikau-course-1"})
response = self.client.get(url)
@@ -69,7 +70,15 @@ def test_pikau_course_content_view_with_valid_slug(self):
def test_pikau_course_content_view_with_invalid_slug(self):
pikau_course_1 = self.test_data.create_pikau_course(1)
+ pikau_unit = self.test_data.create_pikau_unit(pikau_course_1, 1)
url = reverse("pikau:pikau_content", kwargs={"slug": "pikau-course-5"})
response = self.client.get(url)
self.assertEqual(404, response.status_code)
+
+ def test_pikau_course_content_view_with_no_pikau_units(self):
+ pikau_course_1 = self.test_data.create_pikau_course(1)
+
+ url = reverse("pikau:pikau_content", kwargs={"slug": "pikau-course-1"})
+ response = self.client.get(url)
+ self.assertEqual(200, response.status_code)
From 435a7f910a5def993b221559f4f47a702124651e Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:15:50 +1200
Subject: [PATCH 29/72] Make test_licence_model.py adhere to PEP8 styling.
---
tests/files/models/test_licence_model.py | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/tests/files/models/test_licence_model.py b/tests/files/models/test_licence_model.py
index cfa9a1c..95bc60e 100644
--- a/tests/files/models/test_licence_model.py
+++ b/tests/files/models/test_licence_model.py
@@ -4,6 +4,7 @@
from files.models import Licence
from django.db import IntegrityError
+
class LicenceModelTest(BaseTestWithDB):
def __init__(self, *args, **kwargs):
@@ -23,8 +24,8 @@ def test_licence_model_one_licence(self):
self.assertEqual(query_result, licence)
def test_licence_model_two_licences(self):
- licence_1 = self.test_data.create_licence(1)
- licence_2 = self.test_data.create_licence(2)
+ self.test_data.create_licence(1)
+ self.test_data.create_licence(2)
self.assertQuerysetEqual(
Licence.objects.all(),
[
@@ -35,16 +36,16 @@ def test_licence_model_two_licences(self):
)
def test_licence_model_uniqueness(self):
- licence = self.test_data.create_licence(1)
+ self.test_data.create_licence(1)
self.assertRaises(
- IntegrityError,
+ IntegrityError,
lambda: self.test_data.create_licence(1)
)
def test_licence_model_ordering(self):
- licence_3 = self.test_data.create_licence(3)
- licence_1 = self.test_data.create_licence(1)
- licence_2 = self.test_data.create_licence(2)
+ self.test_data.create_licence(3)
+ self.test_data.create_licence(1)
+ self.test_data.create_licence(2)
self.assertQuerysetEqual(
Licence.objects.all(),
[
@@ -52,4 +53,4 @@ def test_licence_model_ordering(self):
"",
"",
],
- )
\ No newline at end of file
+ )
From be3187d137876af8e99657829dbb0aa39fec61f6 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:18:13 +1200
Subject: [PATCH 30/72] Make test_file.py adhere to PEP8 styling.
---
tests/files/models/test_file.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/tests/files/models/test_file.py b/tests/files/models/test_file.py
index 5e1e45c..7b6c58c 100644
--- a/tests/files/models/test_file.py
+++ b/tests/files/models/test_file.py
@@ -4,6 +4,7 @@
from files.models import File
from django.db import IntegrityError
+
class FileModelTest(BaseTestWithDB):
def __init__(self, *args, **kwargs):
@@ -30,8 +31,8 @@ def test_file_model_one_file(self):
self.assertEqual(query_result, file)
def test_file_model_two_files(self):
- file_1 = self.test_data.create_file(1)
- file_2 = self.test_data.create_file(2)
+ self.test_data.create_file(1)
+ self.test_data.create_file(2)
self.assertQuerysetEqual(
File.objects.all(),
[
@@ -42,8 +43,8 @@ def test_file_model_two_files(self):
)
def test_file_model_uniqueness(self):
- file = self.test_data.create_file(1)
+ self.test_data.create_file(1)
self.assertRaises(
- IntegrityError,
+ IntegrityError,
lambda: self.test_data.create_file(1)
)
From b8576a60fa73c4190da4f5622189b8416dfcfa74 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:19:54 +1200
Subject: [PATCH 31/72] Add newline at end of file.
---
tests/pikau/PikauTestDataGenerator.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/pikau/PikauTestDataGenerator.py b/tests/pikau/PikauTestDataGenerator.py
index 2cf7f9a..9004475 100644
--- a/tests/pikau/PikauTestDataGenerator.py
+++ b/tests/pikau/PikauTestDataGenerator.py
@@ -190,4 +190,4 @@ def create_pikau_unit(self, pikau_course, number, module_name=False):
pikau_unit.module_name = "pikau-unit-{}-module-name".format(number)
pikau_unit.save()
- return pikau_unit
\ No newline at end of file
+ return pikau_unit
From f9325105646c8d2b234b93a3e0b8d57e27338567 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:22:25 +1200
Subject: [PATCH 32/72] Make test_glossary_model.py adhere to PEP8 styling.
---
tests/pikau/models/test_glossary_model.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/pikau/models/test_glossary_model.py b/tests/pikau/models/test_glossary_model.py
index a0af797..023377d 100644
--- a/tests/pikau/models/test_glossary_model.py
+++ b/tests/pikau/models/test_glossary_model.py
@@ -17,8 +17,8 @@ def test_glossary_model_one_glossary_term(self):
self.assertEqual(query_result, glossary_term)
def test_glossary_model_two_glossary_terms(self):
- glossary_term_1 = self.test_data.create_glossary_term(1)
- glossary_term_2 = self.test_data.create_glossary_term(2)
+ self.test_data.create_glossary_term(1)
+ self.test_data.create_glossary_term(2)
self.assertQuerysetEqual(
GlossaryTerm.objects.all(),
[
@@ -29,9 +29,9 @@ def test_glossary_model_two_glossary_terms(self):
)
def test_glossary_model_uniqueness(self):
- gloasary_term = self.test_data.create_glossary_term(1)
+ self.test_data.create_glossary_term(1)
self.assertRaises(
- IntegrityError,
+ IntegrityError,
lambda: self.test_data.create_glossary_term(1)
)
From c72dcbdb2eb841e3ead3982b77727edfc32c260e Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:23:56 +1200
Subject: [PATCH 33/72] Make test_goal_model.py adhere to PEP8 styling.
---
tests/pikau/models/test_goal_model.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tests/pikau/models/test_goal_model.py b/tests/pikau/models/test_goal_model.py
index 314f903..a2f3113 100644
--- a/tests/pikau/models/test_goal_model.py
+++ b/tests/pikau/models/test_goal_model.py
@@ -17,8 +17,8 @@ def test_goal_model_one_goal(self):
self.assertEqual(query_result, goal)
def test_goal_model_two_goals(self):
- goal_1 = self.test_data.create_goal(1)
- goal_2 = self.test_data.create_goal(2)
+ self.test_data.create_goal(1)
+ self.test_data.create_goal(2)
self.assertQuerysetEqual(
Goal.objects.all(),
[
@@ -29,9 +29,9 @@ def test_goal_model_two_goals(self):
)
def test_goal_model_uniqueness(self):
- goal = self.test_data.create_goal(1)
+ self.test_data.create_goal(1)
self.assertRaises(
- IntegrityError,
+ IntegrityError,
lambda: self.test_data.create_goal(1)
)
@@ -40,4 +40,4 @@ def test_goal_model_str(self):
self.assertEqual(
goal.__str__(),
"Description for goal 1.
"
- )
\ No newline at end of file
+ )
From 7ed9d6a947b31a49f705a18d7c7c57ec2ac1a9e5 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:27:57 +1200
Subject: [PATCH 34/72] Make test_progress_outcome_model.py adhere to PEP8
styling.
---
.../models/test_progress_outcome_model.py | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/tests/pikau/models/test_progress_outcome_model.py b/tests/pikau/models/test_progress_outcome_model.py
index 139511a..91e4508 100644
--- a/tests/pikau/models/test_progress_outcome_model.py
+++ b/tests/pikau/models/test_progress_outcome_model.py
@@ -12,13 +12,13 @@ def __init__(self, *args, **kwargs):
self.test_data = PikauTestDataGenerator()
def test_progress_outcome_model_one_progress_outcome(self):
- progress_outcome = self.test_data.create_progress_outcome(1)
- query_result = ProgressOutcome.objects.get(slug="progress-outcome-1")
- self.assertEqual(query_result, progress_outcome)
+ progress_outcome = self.test_data.create_progress_outcome(1)
+ query_result = ProgressOutcome.objects.get(slug="progress-outcome-1")
+ self.assertEqual(query_result, progress_outcome)
def test_progress_outcome_model_two_progress_outcomes(self):
- progress_outcome_1 = self.test_data.create_progress_outcome(1)
- progress_outcome_2 = self.test_data.create_progress_outcome(2)
+ self.test_data.create_progress_outcome(1)
+ self.test_data.create_progress_outcome(2)
self.assertQuerysetEqual(
ProgressOutcome.objects.all(),
[
@@ -29,10 +29,10 @@ def test_progress_outcome_model_two_progress_outcomes(self):
)
def test_progress_outcome_model_uniqueness(self):
- progress_outcome = self.test_data.create_progress_outcome(1)
+ self.test_data.create_progress_outcome(1)
self.assertRaises(
- IntegrityError,
- lambda: self.test_data.create_progress_outcome(1),
+ IntegrityError,
+ lambda: self.test_data.create_progress_outcome(1),
)
def test_progress_outcome_model_str(self):
@@ -57,6 +57,3 @@ def test_progress_outcome_model_str(self):
# exemplars="progress-outcome-1",
# ),
# )
-
-
-
From 7f27029175bc539bbc264318b6e65bb98579cdc4 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:32:06 +1200
Subject: [PATCH 35/72] Make test_pikau_course.py adhere to PEP8 styling.
---
tests/pikau/models/test_pikau_course.py | 55 ++++++++++++-------------
1 file changed, 27 insertions(+), 28 deletions(-)
diff --git a/tests/pikau/models/test_pikau_course.py b/tests/pikau/models/test_pikau_course.py
index 8da9cc5..5b086bf 100644
--- a/tests/pikau/models/test_pikau_course.py
+++ b/tests/pikau/models/test_pikau_course.py
@@ -19,59 +19,58 @@ def test_pikau_course_str(self):
)
def test_pikau_course_is_overdue_past_milestone_date(self):
- pikau_course = self.test_data.create_pikau_course(1)
- milestone_date = datetime.now() - dt.timedelta(days=30)
- pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
- self.assertEqual(
+ pikau_course = self.test_data.create_pikau_course(1)
+ milestone_date = datetime.now() - dt.timedelta(days=30)
+ pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
+ self.assertEqual(
pikau_course.is_overdue_milestone,
True
)
def test_pikau_course_is_overdue_future_milestone_date(self):
- pikau_course = self.test_data.create_pikau_course(1)
- milestone_date = datetime.now() + dt.timedelta(days=30)
- pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
- self.assertEqual(
+ pikau_course = self.test_data.create_pikau_course(1)
+ milestone_date = datetime.now() + dt.timedelta(days=30)
+ pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
+ self.assertEqual(
pikau_course.is_overdue_milestone,
False
)
def test_pikau_course_is_overdue_current_milestone_date(self):
- pikau_course = self.test_data.create_pikau_course(1)
- milestone_date = datetime.now()
- pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
- self.assertEqual(
+ pikau_course = self.test_data.create_pikau_course(1)
+ milestone_date = datetime.now()
+ pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
+ self.assertEqual(
pikau_course.is_overdue_milestone,
False
)
def test_pikau_course_is_overdue_course_complete_past_milestone_date(self):
- pikau_course = self.test_data.create_pikau_course(1)
- milestone_date = datetime.now() - dt.timedelta(days=30)
- pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
- pikau_course.status = 7
- self.assertEqual(
+ pikau_course = self.test_data.create_pikau_course(1)
+ milestone_date = datetime.now() - dt.timedelta(days=30)
+ pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
+ pikau_course.status = 7
+ self.assertEqual(
pikau_course.is_overdue_milestone,
False
)
def test_pikau_course_is_overdue_course_complete_future_milestone_date(self):
- pikau_course = self.test_data.create_pikau_course(1)
- milestone_date = datetime.now() + dt.timedelta(days=30)
- pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
- pikau_course.status = 7
- self.assertEqual(
+ pikau_course = self.test_data.create_pikau_course(1)
+ milestone_date = datetime.now() + dt.timedelta(days=30)
+ pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
+ pikau_course.status = 7
+ self.assertEqual(
pikau_course.is_overdue_milestone,
False
)
def test_pikau_course_is_overdue_course_complete_current_milestone_date(self):
- pikau_course = self.test_data.create_pikau_course(1)
- milestone_date = datetime.now()
- pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
- pikau_course.status = 7
- self.assertEqual(
+ pikau_course = self.test_data.create_pikau_course(1)
+ milestone_date = datetime.now()
+ pikau_course.milestone = self.test_data.create_milestone(1, milestone_date.date())
+ pikau_course.status = 7
+ self.assertEqual(
pikau_course.is_overdue_milestone,
False
)
-
From 2fb2f7ce93d6504dd6fdbf146745a3be04d8a1e9 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:35:23 +1200
Subject: [PATCH 36/72] Make test_topic_model.py adhere to PEP8 styling.
---
tests/pikau/models/test_topic_model.py | 30 +++++++++++++-------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/tests/pikau/models/test_topic_model.py b/tests/pikau/models/test_topic_model.py
index 5495c74..f30895d 100644
--- a/tests/pikau/models/test_topic_model.py
+++ b/tests/pikau/models/test_topic_model.py
@@ -12,26 +12,26 @@ def __init__(self, *args, **kwargs):
self.test_data = PikauTestDataGenerator()
def test_topic_model_one_topic(self):
- topic = self.test_data.create_topic(1)
- query_result = Topic.objects.get(slug="topic-1")
- self.assertEqual(query_result, topic)
+ topic = self.test_data.create_topic(1)
+ query_result = Topic.objects.get(slug="topic-1")
+ self.assertEqual(query_result, topic)
def test_topic_model_two_topics(self):
- topic_1 = self.test_data.create_topic(1)
- topic_2 = self.test_data.create_topic(2)
- self.assertQuerysetEqual(
- Topic.objects.all(),
- [
- "",
- "",
- ],
- ordered=False
- )
+ self.test_data.create_topic(1)
+ self.test_data.create_topic(2)
+ self.assertQuerysetEqual(
+ Topic.objects.all(),
+ [
+ "",
+ "",
+ ],
+ ordered=False
+ )
def test_topic_model_uniqueness(self):
- topic = self.test_data.create_topic(1)
+ self.test_data.create_topic(1)
self.assertRaises(
- IntegrityError,
+ IntegrityError,
lambda: self.test_data.create_topic(1)
)
From 0a45171aceaf4f13ca6297edf2984c67c6bebe78 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:36:37 +1200
Subject: [PATCH 37/72] Make test_tag_model.py adhere to PEP8 styling.
---
tests/pikau/models/test_tag_model.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tests/pikau/models/test_tag_model.py b/tests/pikau/models/test_tag_model.py
index 8837e79..f438b61 100644
--- a/tests/pikau/models/test_tag_model.py
+++ b/tests/pikau/models/test_tag_model.py
@@ -17,8 +17,8 @@ def test_tag_model_one_tag(self):
self.assertEqual(query_result, tag)
def test_tag_model_two_tags(self):
- tag_1 = self.test_data.create_tag(1)
- tag_2 = self.test_data.create_tag(2)
+ self.test_data.create_tag(1)
+ self.test_data.create_tag(2)
self.assertQuerysetEqual(
Tag.objects.all(),
[
@@ -29,9 +29,9 @@ def test_tag_model_two_tags(self):
)
def test_tag_model_uniqueness(self):
- tag = self.test_data.create_tag(1)
+ self.test_data.create_tag(1)
self.assertRaises(
- IntegrityError,
+ IntegrityError,
lambda: self.test_data.create_tag(1)
)
@@ -40,4 +40,4 @@ def test_tag_model_str(self):
self.assertEqual(
tag.__str__(),
"tag-1-name"
- )
\ No newline at end of file
+ )
From 35d1e45546a5a0f060cf635cd817367e42732570 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:38:19 +1200
Subject: [PATCH 38/72] Make test_level_model.py adhere to PEP8 styling.
---
tests/pikau/models/test_level_model.py | 30 +++++++++++++-------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/tests/pikau/models/test_level_model.py b/tests/pikau/models/test_level_model.py
index 053438a..5bd6abd 100644
--- a/tests/pikau/models/test_level_model.py
+++ b/tests/pikau/models/test_level_model.py
@@ -12,26 +12,26 @@ def __init__(self, *args, **kwargs):
self.test_data = PikauTestDataGenerator()
def test_level_model_one_level(self):
- level = self.test_data.create_level(1)
- query_result = Level.objects.get(slug="level-1")
- self.assertEqual(query_result, level)
+ level = self.test_data.create_level(1)
+ query_result = Level.objects.get(slug="level-1")
+ self.assertEqual(query_result, level)
def test_level_model_two_levels(self):
- level_1 = self.test_data.create_level(1)
- level_2 = self.test_data.create_level(2)
- self.assertQuerysetEqual(
- Level.objects.all(),
- [
- "",
- "",
- ],
- ordered=False
- )
+ self.test_data.create_level(1)
+ self.test_data.create_level(2)
+ self.assertQuerysetEqual(
+ Level.objects.all(),
+ [
+ "",
+ "",
+ ],
+ ordered=False
+ )
def test_level_model_uniqueness(self):
- level = self.test_data.create_level(1)
+ self.test_data.create_level(1)
self.assertRaises(
- IntegrityError,
+ IntegrityError,
lambda: self.test_data.create_level(1)
)
From 8e3b792fc521bcd827178d1fcbb5b2249bcc9668 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:40:56 +1200
Subject: [PATCH 39/72] Make test_milestone_model.py adhere to PEP8 styling.
---
tests/pikau/models/test_milestone_model.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/tests/pikau/models/test_milestone_model.py b/tests/pikau/models/test_milestone_model.py
index 0534ff7..1ffc6e1 100644
--- a/tests/pikau/models/test_milestone_model.py
+++ b/tests/pikau/models/test_milestone_model.py
@@ -25,8 +25,8 @@ def test_milestone_model_one_milestone(self):
def test_milestone_model_two_milestones(self):
date_1 = self.current_time
date_2 = self.current_time + dt.timedelta(days=30)
- milestone_1 = self.test_data.create_milestone(1, date_1)
- milestone_2 = self.test_data.create_milestone(2, date_2)
+ self.test_data.create_milestone(1, date_1)
+ self.test_data.create_milestone(2, date_2)
self.assertQuerysetEqual(
Milestone.objects.all(),
[
@@ -38,10 +38,10 @@ def test_milestone_model_two_milestones(self):
def test_milestone_model_uniqueness(self):
date = self.current_time
- milestone = self.test_data.create_milestone(1, date)
+ self.test_data.create_milestone(1, date)
self.assertRaises(
- IntegrityError,
- lambda: self.test_data.create_milestone(1, date),
+ IntegrityError,
+ lambda: self.test_data.create_milestone(1, date),
)
def test_milestone_model_str(self):
@@ -65,8 +65,8 @@ def test_milestone_model_is_upcoming_past_date(self):
def test_milestone_model_ordering(self):
date_1 = self.current_time
date_2 = self.current_time + dt.timedelta(days=30)
- milestone_1 = self.test_data.create_milestone(1, date_2)
- milestone_2 = self.test_data.create_milestone(2, date_1)
+ self.test_data.create_milestone(1, date_2)
+ self.test_data.create_milestone(2, date_1)
self.assertQuerysetEqual(
Milestone.objects.all(),
[
From 379c510dbf373268402eb600441ad6c7e0210412 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:43:40 +1200
Subject: [PATCH 40/72] Make test_pikau_unit_model.py adhere to PEP8 styling.
---
tests/pikau/models/test_pikau_unit_model.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/tests/pikau/models/test_pikau_unit_model.py b/tests/pikau/models/test_pikau_unit_model.py
index 3a37a80..cf99b23 100644
--- a/tests/pikau/models/test_pikau_unit_model.py
+++ b/tests/pikau/models/test_pikau_unit_model.py
@@ -19,8 +19,8 @@ def test_pikau_unit_model_one_unit(self):
def test_pikau_unit_model_two_units_with_module_name(self):
pikau_course = self.test_data.create_pikau_course("1")
- pikau_unit_1 = self.test_data.create_pikau_unit(pikau_course, 1, True)
- pikau_unit_2 = self.test_data.create_pikau_unit(pikau_course, 2, True)
+ self.test_data.create_pikau_unit(pikau_course, 1, True)
+ self.test_data.create_pikau_unit(pikau_course, 2, True)
self.assertQuerysetEqual(
PikauUnit.objects.all(),
[
@@ -32,8 +32,8 @@ def test_pikau_unit_model_two_units_with_module_name(self):
def test_pikau_unit_model_two_units_without_module_name(self):
pikau_course = self.test_data.create_pikau_course("1")
- pikau_unit_1 = self.test_data.create_pikau_unit(pikau_course, 1)
- pikau_unit_2 = self.test_data.create_pikau_unit(pikau_course, 2)
+ self.test_data.create_pikau_unit(pikau_course, 1)
+ self.test_data.create_pikau_unit(pikau_course, 2)
self.assertQuerysetEqual(
PikauUnit.objects.all(),
[
@@ -45,9 +45,9 @@ def test_pikau_unit_model_two_units_without_module_name(self):
def test_pikau_unit_model_uniqueness(self):
pikau_course = self.test_data.create_pikau_course("1")
- pikau_unit = self.test_data.create_pikau_unit(pikau_course, 1)
+ self.test_data.create_pikau_unit(pikau_course, 1)
self.assertRaises(
- IntegrityError,
+ IntegrityError,
lambda: self.test_data.create_pikau_unit(pikau_course, 1)
)
@@ -69,9 +69,9 @@ def test_pikau_unit_model_str_without_module(self):
def test_pikau_unit_model_ordering(self):
pikau_course = self.test_data.create_pikau_course("1")
- pikau_unit_1 = self.test_data.create_pikau_unit(pikau_course, 1)
- pikau_unit_2 = self.test_data.create_pikau_unit(pikau_course, 2)
- pikau_unit_3 = self.test_data.create_pikau_unit(pikau_course, 3)
+ self.test_data.create_pikau_unit(pikau_course, 1)
+ self.test_data.create_pikau_unit(pikau_course, 2)
+ self.test_data.create_pikau_unit(pikau_course, 3)
self.assertQuerysetEqual(
PikauUnit.objects.all(),
[
From 9f9a162b367e982317fafb71104e4fb3367431ff Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:45:35 +1200
Subject: [PATCH 41/72] Make test_goal_view.py adhere to PEP8 styling.
---
tests/pikau/views/test_goal_view.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/tests/pikau/views/test_goal_view.py b/tests/pikau/views/test_goal_view.py
index adcc1d3..bd2e708 100644
--- a/tests/pikau/views/test_goal_view.py
+++ b/tests/pikau/views/test_goal_view.py
@@ -17,7 +17,7 @@ def test_pikau_goal_view_with_no_goals(self):
self.assertEqual(len(response.context["goals"]), 0)
def test_pikau_goal_view_with_one_goal(self):
- goal = self.test_data.create_goal(1)
+ self.test_data.create_goal(1)
url = reverse("pikau:goal_list")
response = self.client.get(url)
@@ -29,8 +29,8 @@ def test_pikau_goal_view_with_one_goal(self):
)
def test_pikau_goal_view_with_two_goals(self):
- goal_1 = self.test_data.create_goal(1)
- goal_2 = self.test_data.create_goal(2)
+ self.test_data.create_goal(1)
+ self.test_data.create_goal(2)
url = reverse("pikau:goal_list")
response = self.client.get(url)
@@ -39,15 +39,15 @@ def test_pikau_goal_view_with_two_goals(self):
self.assertQuerysetEqual(
response.context["goals"],
[
- "Description for goal 1.>",
+ "Description for goal 1.>",
"Description for goal 2.>",
]
)
def test_pikau_goal_view_order(self):
- goal_3 = self.test_data.create_goal(3)
- goal_2 = self.test_data.create_goal(2)
- goal_1 = self.test_data.create_goal(1)
+ self.test_data.create_goal(3)
+ self.test_data.create_goal(2)
+ self.test_data.create_goal(1)
url = reverse("pikau:goal_list")
response = self.client.get(url)
@@ -56,8 +56,8 @@ def test_pikau_goal_view_order(self):
self.assertQuerysetEqual(
response.context["goals"],
[
- "Description for goal 1.>",
+ "Description for goal 1.>",
"Description for goal 2.>",
"Description for goal 3.>",
]
- )
\ No newline at end of file
+ )
From b34d6ceb5f764932ca9dbfff034e8e6f64241f22 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:48:46 +1200
Subject: [PATCH 42/72] Make test_readiness_level_view.py adhere to PEP8
styling.
---
tests/pikau/views/test_readiness_level_view.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tests/pikau/views/test_readiness_level_view.py b/tests/pikau/views/test_readiness_level_view.py
index 1a6694b..6b33d32 100644
--- a/tests/pikau/views/test_readiness_level_view.py
+++ b/tests/pikau/views/test_readiness_level_view.py
@@ -14,7 +14,7 @@ def test_readiness_level_list_view_with_no_courses(self):
url = reverse("pikau:readiness_level_list")
response = self.client.get(url)
self.assertEqual(200, response.status_code)
-
+
readiness_levels = response.context["readiness_levels"]
for level in range(1, 6):
level_data = readiness_levels[level]
@@ -22,8 +22,8 @@ def test_readiness_level_list_view_with_no_courses(self):
self.assertEqual(num_of_courses_on_level, 0)
def test_readiness_level_list_view_with_one_course_for_all_levels(self):
- # create 1 course under each readiness level
- for level in range(1, 6):
+ # create 1 course under each readiness level
+ for level in range(1, 6):
pikau_course = self.test_data.create_pikau_course(level)
pikau_course.readiness_level = level
pikau_course.save()
@@ -31,7 +31,7 @@ def test_readiness_level_list_view_with_one_course_for_all_levels(self):
url = reverse("pikau:readiness_level_list")
response = self.client.get(url)
self.assertEqual(200, response.status_code)
-
+
readiness_levels = response.context["readiness_levels"]
level_data = readiness_levels[level]
num_of_courses_on_level = level_data["count"]
@@ -53,7 +53,7 @@ def test_readiness_level_list_view_multiple_courses_one_level(self):
url = reverse("pikau:readiness_level_list")
response = self.client.get(url)
self.assertEqual(200, response.status_code)
-
+
readiness_levels = response.context["readiness_levels"]
level_data = readiness_levels[4]
num_of_courses_on_level = level_data["count"]
@@ -83,7 +83,7 @@ def test_readiness_level_list_view_multiple_courses_multiple_levels(self):
url = reverse("pikau:readiness_level_list")
response = self.client.get(url)
self.assertEqual(200, response.status_code)
-
+
readiness_levels = response.context["readiness_levels"]
level_1_data = readiness_levels[1]
level_2_data = readiness_levels[2]
From 04b031f030480b76a392e91200c66cd08833d3c0 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:50:27 +1200
Subject: [PATCH 43/72] Make test_tag_view.py adhere to PEP8 styling.
---
tests/pikau/views/test_tag_view.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/tests/pikau/views/test_tag_view.py b/tests/pikau/views/test_tag_view.py
index 9e1d06a..01a485d 100644
--- a/tests/pikau/views/test_tag_view.py
+++ b/tests/pikau/views/test_tag_view.py
@@ -11,7 +11,7 @@ def __init__(self, *args, **kwargs):
self.test_data = PikauTestDataGenerator()
def test_pikau_tag_view_with_valid_slug(self):
- tag = self.test_data.create_tag(1)
+ self.test_data.create_tag(1)
url = reverse("pikau:tag", kwargs={"slug": "tag-1"})
response = self.client.get(url)
@@ -19,7 +19,7 @@ def test_pikau_tag_view_with_valid_slug(self):
self.assertEqual(url, "/pikau/tags/tag-1/")
def test_pikau_tag_view_with_invalid_slug(self):
- tag = self.test_data.create_tag(1)
+ self.test_data.create_tag(1)
url = reverse("pikau:tag", kwargs={"slug": "tag-5"})
response = self.client.get(url)
@@ -32,7 +32,7 @@ def test_pikau_tag_list_view_with_no_tags(self):
self.assertEqual(len(response.context["tags"]), 0)
def test_pikau_tag_list_view_with_one_tag(self):
- tag = self.test_data.create_tag(1)
+ self.test_data.create_tag(1)
url = reverse("pikau:tag_list")
response = self.client.get(url)
@@ -44,8 +44,8 @@ def test_pikau_tag_list_view_with_one_tag(self):
)
def test_pikau_tag_list_view_with_two_tags(self):
- tag_1 = self.test_data.create_tag(1)
- tag_2 = self.test_data.create_tag(2)
+ self.test_data.create_tag(1)
+ self.test_data.create_tag(2)
url = reverse("pikau:tag_list")
response = self.client.get(url)
@@ -60,9 +60,9 @@ def test_pikau_tag_list_view_with_two_tags(self):
)
def test_pikau_tag_list_view_order(self):
- tag_3 = self.test_data.create_tag(3)
- tag_2 = self.test_data.create_tag(2)
- tag_1 = self.test_data.create_tag(1)
+ self.test_data.create_tag(3)
+ self.test_data.create_tag(2)
+ self.test_data.create_tag(1)
url = reverse("pikau:tag_list")
response = self.client.get(url)
@@ -75,4 +75,4 @@ def test_pikau_tag_list_view_order(self):
"",
"",
]
- )
\ No newline at end of file
+ )
From 0a660cf35f713bea4ec5ac71ef7ef2322834194f Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 11:55:12 +1200
Subject: [PATCH 44/72] Make test_pikau_unit_view.py adhere to PEP8 styling.
---
tests/pikau/views/test_pikau_unit_view.py | 26 +++++++++++------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/tests/pikau/views/test_pikau_unit_view.py b/tests/pikau/views/test_pikau_unit_view.py
index 80955d8..5d695f8 100644
--- a/tests/pikau/views/test_pikau_unit_view.py
+++ b/tests/pikau/views/test_pikau_unit_view.py
@@ -12,7 +12,7 @@ def __init__(self, *args, **kwargs):
def test_pikau_unit_view_with_valid_slug(self):
pikau_course = self.test_data.create_pikau_course(1)
- pikau_unit = self.test_data.create_pikau_unit(pikau_course, 1)
+ self.test_data.create_pikau_unit(pikau_course, 1)
kwargs = {
"course_slug": "pikau-course-1",
@@ -22,13 +22,13 @@ def test_pikau_unit_view_with_valid_slug(self):
response = self.client.get(url)
self.assertEqual(200, response.status_code)
self.assertEqual(
- url,
+ url,
"/pikau/pikau-courses/pikau-course-1/content/pikau-unit-1/"
)
def test_pikau_unit_view_with_invalid_unit_slug(self):
pikau_course = self.test_data.create_pikau_course(1)
- pikau_unit = self.test_data.create_pikau_unit(pikau_course, 1)
+ self.test_data.create_pikau_unit(pikau_course, 1)
kwargs = {
"course_slug": "pikau-course-1",
@@ -40,7 +40,7 @@ def test_pikau_unit_view_with_invalid_unit_slug(self):
def test_pikau_unit_view_with_invalid_course_slug(self):
pikau_course = self.test_data.create_pikau_course(1)
- pikau_unit = self.test_data.create_pikau_unit(pikau_course, 1)
+ self.test_data.create_pikau_unit(pikau_course, 1)
kwargs = {
"course_slug": "pikau-course-2",
@@ -52,8 +52,8 @@ def test_pikau_unit_view_with_invalid_course_slug(self):
def test_pikau_unit_view_context_with_previous_unit(self):
pikau_course = self.test_data.create_pikau_course(1)
- pikau_unit_1 = self.test_data.create_pikau_unit(pikau_course, 1)
- pikau_unit_2 = self.test_data.create_pikau_unit(pikau_course, 2)
+ self.test_data.create_pikau_unit(pikau_course, 1)
+ self.test_data.create_pikau_unit(pikau_course, 2)
kwargs = {
"course_slug": "pikau-course-1",
@@ -67,8 +67,8 @@ def test_pikau_unit_view_context_with_previous_unit(self):
def test_pikau_unit_view_context_with_next_unit(self):
pikau_course = self.test_data.create_pikau_course(1)
- pikau_unit_1 = self.test_data.create_pikau_unit(pikau_course, 1)
- pikau_unit_2 = self.test_data.create_pikau_unit(pikau_course, 2)
+ self.test_data.create_pikau_unit(pikau_course, 1)
+ self.test_data.create_pikau_unit(pikau_course, 2)
kwargs = {
"course_slug": "pikau-course-1",
@@ -82,9 +82,9 @@ def test_pikau_unit_view_context_with_next_unit(self):
def test_pikau_unit_view_context_with_previous_and_next_unit(self):
pikau_course = self.test_data.create_pikau_course(1)
- pikau_unit_1 = self.test_data.create_pikau_unit(pikau_course, 1)
- pikau_unit_2 = self.test_data.create_pikau_unit(pikau_course, 2)
- pikau_unit_3 = self.test_data.create_pikau_unit(pikau_course, 3)
+ self.test_data.create_pikau_unit(pikau_course, 1)
+ self.test_data.create_pikau_unit(pikau_course, 2)
+ self.test_data.create_pikau_unit(pikau_course, 3)
kwargs = {
"course_slug": "pikau-course-1",
@@ -101,7 +101,7 @@ def test_pikau_unit_view_context_with_previous_and_next_unit(self):
def test_pikau_unit_view_context_with_no_previous_or_next_units(self):
pikau_course = self.test_data.create_pikau_course(1)
- pikau_unit_1 = self.test_data.create_pikau_unit(pikau_course, 1)
+ self.test_data.create_pikau_unit(pikau_course, 1)
kwargs = {
"course_slug": "pikau-course-1",
@@ -114,4 +114,4 @@ def test_pikau_unit_view_context_with_no_previous_or_next_units(self):
previous_unit = response.context["previous_unit"]
self.assertEqual(previous_unit, None)
next_unit = response.context["next_unit"]
- self.assertEqual(next_unit, None)
\ No newline at end of file
+ self.assertEqual(next_unit, None)
From c131729261e6b1da38954112ccb594c1a483bafa Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 12:03:37 +1200
Subject: [PATCH 45/72] Add back in needed variables that were accidentally
removed.
---
tests/pikau/views/test_pikau_unit_view.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/tests/pikau/views/test_pikau_unit_view.py b/tests/pikau/views/test_pikau_unit_view.py
index 5d695f8..088e0f2 100644
--- a/tests/pikau/views/test_pikau_unit_view.py
+++ b/tests/pikau/views/test_pikau_unit_view.py
@@ -52,7 +52,7 @@ def test_pikau_unit_view_with_invalid_course_slug(self):
def test_pikau_unit_view_context_with_previous_unit(self):
pikau_course = self.test_data.create_pikau_course(1)
- self.test_data.create_pikau_unit(pikau_course, 1)
+ previous_pikau_unit = self.test_data.create_pikau_unit(pikau_course, 1)
self.test_data.create_pikau_unit(pikau_course, 2)
kwargs = {
@@ -63,12 +63,12 @@ def test_pikau_unit_view_context_with_previous_unit(self):
response = self.client.get(url)
self.assertEqual(200, response.status_code)
previous_unit = response.context["previous_unit"]
- self.assertEqual(previous_unit, pikau_unit_1)
+ self.assertEqual(previous_unit, previous_pikau_unit)
def test_pikau_unit_view_context_with_next_unit(self):
pikau_course = self.test_data.create_pikau_course(1)
self.test_data.create_pikau_unit(pikau_course, 1)
- self.test_data.create_pikau_unit(pikau_course, 2)
+ next_pikau_unit = self.test_data.create_pikau_unit(pikau_course, 2)
kwargs = {
"course_slug": "pikau-course-1",
@@ -78,13 +78,13 @@ def test_pikau_unit_view_context_with_next_unit(self):
response = self.client.get(url)
self.assertEqual(200, response.status_code)
next_unit = response.context["next_unit"]
- self.assertEqual(next_unit, pikau_unit_2)
+ self.assertEqual(next_unit, next_pikau_unit)
def test_pikau_unit_view_context_with_previous_and_next_unit(self):
pikau_course = self.test_data.create_pikau_course(1)
- self.test_data.create_pikau_unit(pikau_course, 1)
+ previous_pikau_unit = self.test_data.create_pikau_unit(pikau_course, 1)
self.test_data.create_pikau_unit(pikau_course, 2)
- self.test_data.create_pikau_unit(pikau_course, 3)
+ next_pikau_unit = self.test_data.create_pikau_unit(pikau_course, 3)
kwargs = {
"course_slug": "pikau-course-1",
@@ -95,9 +95,9 @@ def test_pikau_unit_view_context_with_previous_and_next_unit(self):
self.assertEqual(200, response.status_code)
previous_unit = response.context["previous_unit"]
- self.assertEqual(previous_unit, pikau_unit_1)
+ self.assertEqual(previous_unit, previous_pikau_unit)
next_unit = response.context["next_unit"]
- self.assertEqual(next_unit, pikau_unit_3)
+ self.assertEqual(next_unit, next_pikau_unit)
def test_pikau_unit_view_context_with_no_previous_or_next_units(self):
pikau_course = self.test_data.create_pikau_course(1)
From 193be70647c02065911c44531ca7790565f139f3 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 12:04:05 +1200
Subject: [PATCH 46/72] Make test_pikau_course_view.py adhere to PEP8 styling.
---
tests/pikau/views/test_pikau_course_view.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/tests/pikau/views/test_pikau_course_view.py b/tests/pikau/views/test_pikau_course_view.py
index 39f69b9..bd93bdf 100644
--- a/tests/pikau/views/test_pikau_course_view.py
+++ b/tests/pikau/views/test_pikau_course_view.py
@@ -17,7 +17,7 @@ def test_pikau_course_list_view_with_no_courses(self):
self.assertEqual(len(response.context["pikau_courses"]), 0)
def test_pikau_course_list_view_with_one_course(self):
- pikau_course = self.test_data.create_pikau_course(1)
+ self.test_data.create_pikau_course(1)
url = reverse("pikau:pikau_course_list")
response = self.client.get(url)
@@ -29,8 +29,8 @@ def test_pikau_course_list_view_with_one_course(self):
)
def test_pikau_course_list_view_with_two_courses(self):
- pikau_course_1 = self.test_data.create_pikau_course(1)
- pikau_course_2 = self.test_data.create_pikau_course(2)
+ self.test_data.create_pikau_course(1)
+ self.test_data.create_pikau_course(2)
url = reverse("pikau:pikau_course_list")
response = self.client.get(url)
@@ -45,7 +45,7 @@ def test_pikau_course_list_view_with_two_courses(self):
)
def test_pikau_course_view_with_valid_slug(self):
- pikau_course_1 = self.test_data.create_pikau_course(1)
+ self.test_data.create_pikau_course(1)
url = reverse("pikau:pikau_course", kwargs={"slug": "pikau-course-1"})
response = self.client.get(url)
@@ -53,7 +53,7 @@ def test_pikau_course_view_with_valid_slug(self):
self.assertEqual(url, "/pikau/pikau-courses/pikau-course-1/")
def test_pikau_course_view_with_invalid_slug(self):
- pikau_course_1 = self.test_data.create_pikau_course(1)
+ self.test_data.create_pikau_course(1)
url = reverse("pikau:pikau_course", kwargs={"slug": "pikau-course-5"})
response = self.client.get(url)
@@ -61,7 +61,7 @@ def test_pikau_course_view_with_invalid_slug(self):
def test_pikau_course_content_view_with_valid_slug(self):
pikau_course_1 = self.test_data.create_pikau_course(1)
- pikau_unit = self.test_data.create_pikau_unit(pikau_course_1, 1)
+ self.test_data.create_pikau_unit(pikau_course_1, 1)
url = reverse("pikau:pikau_content", kwargs={"slug": "pikau-course-1"})
response = self.client.get(url)
@@ -70,14 +70,14 @@ def test_pikau_course_content_view_with_valid_slug(self):
def test_pikau_course_content_view_with_invalid_slug(self):
pikau_course_1 = self.test_data.create_pikau_course(1)
- pikau_unit = self.test_data.create_pikau_unit(pikau_course_1, 1)
+ self.test_data.create_pikau_unit(pikau_course_1, 1)
url = reverse("pikau:pikau_content", kwargs={"slug": "pikau-course-5"})
response = self.client.get(url)
self.assertEqual(404, response.status_code)
def test_pikau_course_content_view_with_no_pikau_units(self):
- pikau_course_1 = self.test_data.create_pikau_course(1)
+ self.test_data.create_pikau_course(1)
url = reverse("pikau:pikau_content", kwargs={"slug": "pikau-course-1"})
response = self.client.get(url)
From eaf01d1084e2ddb1f2d0db9e429e4d52dfbe1685 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 12:05:15 +1200
Subject: [PATCH 47/72] Make test_pathways_view.py adhere to PEP8 styling.
---
tests/pikau/views/test_pathways_view.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/pikau/views/test_pathways_view.py b/tests/pikau/views/test_pathways_view.py
index 9f1cdad..49c59d8 100644
--- a/tests/pikau/views/test_pathways_view.py
+++ b/tests/pikau/views/test_pathways_view.py
@@ -16,7 +16,7 @@ def test_pathways_view(self):
def test_pathways_view_context_readiness_levels(self):
response = self.client.get(reverse("pikau:pathways"))
- self.assertEqual(200, response.status_code)
+ self.assertEqual(200, response.status_code)
self.assertEqual(response.context["readiness_levels"], READINESS_LEVELS)
- # TODO: test pathways notation - utils test.
\ No newline at end of file
+ # TODO: test pathways notation - utils test.
From 81644e97e1fd5a2512334e36e95ab8a51834a913 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 12:08:42 +1200
Subject: [PATCH 48/72] Make test_topic_view adhere to PEP8 styling.
---
tests/pikau/views/test_topic_view.py | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/tests/pikau/views/test_topic_view.py b/tests/pikau/views/test_topic_view.py
index 8ba3d0f..269fc05 100644
--- a/tests/pikau/views/test_topic_view.py
+++ b/tests/pikau/views/test_topic_view.py
@@ -11,7 +11,7 @@ def __init__(self, *args, **kwargs):
self.test_data = PikauTestDataGenerator()
def test_pikau_topic_view_with_valid_slug(self):
- topic = self.test_data.create_topic(1)
+ self.test_data.create_topic(1)
url = reverse("pikau:topic", kwargs={"slug": "topic-1"})
response = self.client.get(url)
@@ -19,7 +19,7 @@ def test_pikau_topic_view_with_valid_slug(self):
self.assertEqual(url, "/pikau/topics/view/topic-1/")
def test_pikau_topic_view_with_invalid_slug(self):
- topic = self.test_data.create_topic(1)
+ self.test_data.create_topic(1)
url = reverse("pikau:topic", kwargs={"slug": "topic-5"})
response = self.client.get(url)
@@ -32,7 +32,7 @@ def test_pikau_topic_list_view_with_no_topics(self):
self.assertEqual(len(response.context["topics"]), 0)
def test_pikau_topic_list_view_with_one_topic(self):
- topic = self.test_data.create_topic(1)
+ self.test_data.create_topic(1)
url = reverse("pikau:topic_list")
response = self.client.get(url)
@@ -44,8 +44,8 @@ def test_pikau_topic_list_view_with_one_topic(self):
)
def test_pikau_topic_list_view_with_two_topics(self):
- topic_1 = self.test_data.create_topic(1)
- topic_2 = self.test_data.create_topic(2)
+ self.test_data.create_topic(1)
+ self.test_data.create_topic(2)
url = reverse("pikau:topic_list")
response = self.client.get(url)
@@ -54,16 +54,15 @@ def test_pikau_topic_list_view_with_two_topics(self):
self.assertQuerysetEqual(
response.context["topics"],
[
- "",
- "",
+ "",
+ "",
]
)
-
def test_pikau_topic_list_view_order(self):
- topic_3 = self.test_data.create_topic(3)
- topic_2 = self.test_data.create_topic(2)
- topic_1 = self.test_data.create_topic(1)
+ self.test_data.create_topic(3)
+ self.test_data.create_topic(2)
+ self.test_data.create_topic(1)
url = reverse("pikau:topic_list")
response = self.client.get(url)
@@ -76,4 +75,4 @@ def test_pikau_topic_list_view_order(self):
"",
"",
]
- )
\ No newline at end of file
+ )
From 58a6f6f31c429f582165c4d69453efb82a669ec1 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 12:10:07 +1200
Subject: [PATCH 49/72] Make test_level_view.py adhere to PEP8 styling.
---
tests/pikau/views/test_level_view.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/tests/pikau/views/test_level_view.py b/tests/pikau/views/test_level_view.py
index d9ea7f8..f0444c3 100644
--- a/tests/pikau/views/test_level_view.py
+++ b/tests/pikau/views/test_level_view.py
@@ -11,7 +11,7 @@ def __init__(self, *args, **kwargs):
self.test_data = PikauTestDataGenerator()
def test_pikau_level_view_with_valid_slug(self):
- level = self.test_data.create_level(1)
+ self.test_data.create_level(1)
url = reverse("pikau:level", kwargs={"slug": "level-1"})
response = self.client.get(url)
@@ -19,7 +19,7 @@ def test_pikau_level_view_with_valid_slug(self):
self.assertEqual(url, "/pikau/levels/level-1/")
def test_pikau_level_view_with_invalid_slug(self):
- level = self.test_data.create_level(1)
+ self.test_data.create_level(1)
url = reverse("pikau:level", kwargs={"slug": "level-5"})
response = self.client.get(url)
@@ -32,7 +32,7 @@ def test_pikau_level_list_view_with_no_levels(self):
self.assertEqual(len(response.context["levels"]), 0)
def test_pikau_level_list_view_with_one_level(self):
- level = self.test_data.create_level(1)
+ self.test_data.create_level(1)
url = reverse("pikau:level_list")
response = self.client.get(url)
@@ -44,8 +44,8 @@ def test_pikau_level_list_view_with_one_level(self):
)
def test_pikau_level_list_view_with_two_levels(self):
- level_1 = self.test_data.create_level(1)
- level_2 = self.test_data.create_level(2)
+ self.test_data.create_level(1)
+ self.test_data.create_level(2)
url = reverse("pikau:level_list")
response = self.client.get(url)
@@ -60,9 +60,9 @@ def test_pikau_level_list_view_with_two_levels(self):
)
def test_pikau_level_list_view_order(self):
- level_3 = self.test_data.create_level(3)
- level_2 = self.test_data.create_level(2)
- level_1 = self.test_data.create_level(1)
+ self.test_data.create_level(3)
+ self.test_data.create_level(2)
+ self.test_data.create_level(1)
url = reverse("pikau:level_list")
response = self.client.get(url)
@@ -75,4 +75,4 @@ def test_pikau_level_list_view_order(self):
"",
"",
]
- )
\ No newline at end of file
+ )
From f31d0db2e0b77092d36bb3a5e31a09330cf0ff71 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 12:12:38 +1200
Subject: [PATCH 50/72] Make test_documentation_view.py adhere to PEP8 styling.
---
tests/pikau/views/test_documentation_view.py | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/tests/pikau/views/test_documentation_view.py b/tests/pikau/views/test_documentation_view.py
index 7962c88..68471e8 100644
--- a/tests/pikau/views/test_documentation_view.py
+++ b/tests/pikau/views/test_documentation_view.py
@@ -4,9 +4,7 @@
from http import HTTPStatus
from pikau.models import (
- Level,
ProgressOutcome,
- Topic,
Tag,
STATUS_CHOICES,
READINESS_LEVELS,
@@ -31,13 +29,13 @@ def test_documentation_view_context_status_stages(self):
self.assertEqual(response.context["status_stages"], STATUS_CHOICES)
def test_documentation_view_context_topics(self):
- topic_1 = self.test_data.create_topic(1)
- topic_2 = self.test_data.create_topic(2)
+ self.test_data.create_topic(1)
+ self.test_data.create_topic(2)
response = self.client.get(reverse("pikau:docs"))
self.assertEqual(HTTPStatus.OK, response.status_code)
self.assertQuerysetEqual(
- response.context["topics"],
+ response.context["topics"],
[
"",
"",
@@ -45,8 +43,8 @@ def test_documentation_view_context_topics(self):
)
def test_documentation_view_context_levels(self):
- level_1 = self.test_data.create_level(1)
- level_2 = self.test_data.create_level(2)
+ self.test_data.create_level(1)
+ self.test_data.create_level(2)
response = self.client.get(reverse("pikau:docs"))
self.assertEqual(HTTPStatus.OK, response.status_code)
@@ -59,8 +57,8 @@ def test_documentation_view_context_levels(self):
)
def test_documentation_view_context_progress_outcomes(self):
- progress_outcome_1 = self.test_data.create_progress_outcome(1)
- progress_outcome_2 = self.test_data.create_progress_outcome(2)
+ self.test_data.create_progress_outcome(1)
+ self.test_data.create_progress_outcome(2)
response = self.client.get(reverse("pikau:docs"))
self.assertEqual(HTTPStatus.OK, response.status_code)
@@ -110,4 +108,4 @@ def test_documentation_view_with_no_data(self):
self.assertQuerysetEqual(response.context["topics"], [])
self.assertQuerysetEqual(response.context["levels"], [])
self.assertQuerysetEqual(response.context["progress_outcomes"], [])
- self.assertEqual(response.context["readiness_levels"], READINESS_LEVELS)
\ No newline at end of file
+ self.assertEqual(response.context["readiness_levels"], READINESS_LEVELS)
From f3c0e55c13fbc609cd796b2d58a70dd498557fc0 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 12:15:40 +1200
Subject: [PATCH 51/72] Make test_milestone_view.py adhere to PEP8 styling.
---
tests/pikau/views/test_milestone_view.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/tests/pikau/views/test_milestone_view.py b/tests/pikau/views/test_milestone_view.py
index fe1ba9b..07c9496 100644
--- a/tests/pikau/views/test_milestone_view.py
+++ b/tests/pikau/views/test_milestone_view.py
@@ -22,7 +22,7 @@ def test_pikau_milestone_list_view_with_no_milestones(self):
self.assertEqual(len(response.context["milestones"]), 0)
def test_pikau_milestone_list_view_with_one_milestone(self):
- milestone = self.test_data.create_milestone(1, self.current_time)
+ self.test_data.create_milestone(1, self.current_time)
url = reverse("pikau:milestone_list")
response = self.client.get(url)
@@ -36,8 +36,8 @@ def test_pikau_milestone_list_view_with_one_milestone(self):
def test_pikau_milestone_list_view_order(self):
date_1 = self.current_time
date_2 = self.current_time + dt.timedelta(days=30)
- milestone_1 = self.test_data.create_milestone(1, date_2)
- milestone_2 = self.test_data.create_milestone(2, date_1)
+ self.test_data.create_milestone(1, date_2)
+ self.test_data.create_milestone(2, date_1)
url = reverse("pikau:milestone_list")
response = self.client.get(url)
@@ -51,7 +51,7 @@ def test_pikau_milestone_list_view_order(self):
)
def test_pikau_milestone_list_view_with_two_milestones(self):
- milestone = self.test_data.create_milestone(1, self.current_time)
+ self.test_data.create_milestone(1, self.current_time)
url = reverse("pikau:milestone_list")
response = self.client.get(url)
@@ -75,7 +75,7 @@ def test_pikau_milestone_list_view_milestone_status_course_count(self):
self.assertEqual(200, response.status_code)
milestones = response.context["milestones"]
- milestone_1 = milestones[0]
+ milestone_1 = milestones[0]
milestone_1_status_3_course_count = milestone_1.status[3]
milestone_1_status_7_course_count = milestone_1.status[7]
self.assertEqual(milestone_1_status_3_course_count, 1)
@@ -103,17 +103,17 @@ def test_milestone_view_no_milestones(self):
self.assertEqual(404, response.status_code)
def test_milestone_view_with_valid_pk(self):
- milestone = self.test_data.create_milestone(1, self.current_time)
+ self.test_data.create_milestone(1, self.current_time)
url = reverse("pikau:milestone", kwargs={"pk": 1})
response = self.client.get(url)
self.assertEqual(200, response.status_code)
self.assertEqual(
- url,
+ url,
"/pikau/milestones/1/"
)
def test_milestone_view_with_invalid_pk(self):
- milestone = self.test_data.create_milestone(1, self.current_time)
+ self.test_data.create_milestone(1, self.current_time)
url = reverse("pikau:milestone", kwargs={"pk": 5})
response = self.client.get(url)
self.assertEqual(404, response.status_code)
From d696aa839f250cd0920233a2515c02fc9fa78cfc Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 12:16:57 +1200
Subject: [PATCH 52/72] Make test_progress_outcome_view.py adhere to PEP8
styling.
---
tests/pikau/views/test_progress_outcome_view.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/pikau/views/test_progress_outcome_view.py b/tests/pikau/views/test_progress_outcome_view.py
index 5f4bfeb..0cde5f6 100644
--- a/tests/pikau/views/test_progress_outcome_view.py
+++ b/tests/pikau/views/test_progress_outcome_view.py
@@ -11,7 +11,7 @@ def __init__(self, *args, **kwargs):
self.test_data = PikauTestDataGenerator()
def test_pikau_progress_outcome_view_with_valid_slug(self):
- progress_outcome = self.test_data.create_progress_outcome(1)
+ self.test_data.create_progress_outcome(1)
kwargs = {
"slug": "progress-outcome-1",
@@ -20,12 +20,12 @@ def test_pikau_progress_outcome_view_with_valid_slug(self):
response = self.client.get(url)
self.assertEqual(200, response.status_code)
self.assertEqual(
- url,
+ url,
"/pikau/progress-outcomes/progress-outcome-1/"
)
def test_pikau_progress_outcome_view_with_invalid_slug(self):
- progress_outcome = self.test_data.create_progress_outcome(1)
+ self.test_data.create_progress_outcome(1)
kwargs = {
"slug": "progress-outcome-5",
@@ -34,4 +34,4 @@ def test_pikau_progress_outcome_view_with_invalid_slug(self):
response = self.client.get(url)
self.assertEqual(404, response.status_code)
- # TODO: Add tests for heatmap.
\ No newline at end of file
+ # TODO: Add tests for heatmap.
From 7baaf0c1537800d0350a833dc86f2ddd571c694e Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 12:18:44 +1200
Subject: [PATCH 53/72] Make test_glossary_view.py adhere to PEP8 styling.
---
tests/pikau/views/test_glossary_view.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tests/pikau/views/test_glossary_view.py b/tests/pikau/views/test_glossary_view.py
index 7a15a4e..f9b9299 100644
--- a/tests/pikau/views/test_glossary_view.py
+++ b/tests/pikau/views/test_glossary_view.py
@@ -29,8 +29,8 @@ def test_pikau_glossary_view_with_one_definition(self):
)
def test_pikau_glossary_view_with_two_definitions(self):
- term_1 = self.test_data.create_glossary_term(1)
- term_2 = self.test_data.create_glossary_term(2)
+ self.test_data.create_glossary_term(1)
+ self.test_data.create_glossary_term(2)
url = reverse("pikau:glossaryterm_list")
response = self.client.get(url)
@@ -39,16 +39,16 @@ def test_pikau_glossary_view_with_two_definitions(self):
self.assertQuerysetEqual(
response.context["glossaryterm_list"],
[
- "",
+ "",
"",
],
ordered=False
)
def test_pikau_glossary_view_order(self):
- term_3 = self.test_data.create_glossary_term(3)
- term_2 = self.test_data.create_glossary_term(2)
- term_1 = self.test_data.create_glossary_term(1)
+ self.test_data.create_glossary_term(3)
+ self.test_data.create_glossary_term(2)
+ self.test_data.create_glossary_term(1)
url = reverse("pikau:glossaryterm_list")
response = self.client.get(url)
From 885a8aa5f76ccd901ccc5d5c8ce4e40be993472d Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 12:27:21 +1200
Subject: [PATCH 54/72] Align hanging indent.
---
tests/pikau/models/test_topic_model.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/pikau/models/test_topic_model.py b/tests/pikau/models/test_topic_model.py
index f30895d..7361dbb 100644
--- a/tests/pikau/models/test_topic_model.py
+++ b/tests/pikau/models/test_topic_model.py
@@ -25,7 +25,7 @@ def test_topic_model_two_topics(self):
"",
"",
],
- ordered=False
+ ordered=False
)
def test_topic_model_uniqueness(self):
From 0e7770dd81a7bec130135d913ca879a839022bf0 Mon Sep 17 00:00:00 2001
From: Courtney Bracefield
Date: Tue, 5 Jun 2018 12:28:40 +1200
Subject: [PATCH 55/72] Remove unnecessary variable assignment.
---
tests/pikau/views/test_glossary_view.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/pikau/views/test_glossary_view.py b/tests/pikau/views/test_glossary_view.py
index f9b9299..c608f3d 100644
--- a/tests/pikau/views/test_glossary_view.py
+++ b/tests/pikau/views/test_glossary_view.py
@@ -17,7 +17,7 @@ def test_pikau_glossary_view_with_no_definitions(self):
self.assertEqual(len(response.context["glossaryterm_list"]), 0)
def test_pikau_glossary_view_with_one_definition(self):
- term = self.test_data.create_glossary_term(1)
+ self.test_data.create_glossary_term(1)
url = reverse("pikau:glossaryterm_list")
response = self.client.get(url)
From 5e9ee0db614801787f5b85404ab3f87cfdc5b2e0 Mon Sep 17 00:00:00 2001
From: Jack Morgan
Date: Thu, 7 Jun 2018 11:25:56 +1200
Subject: [PATCH 56/72] Fix bug where file licence warning displayed wrong
licence
Fixes #60
---
files/views.py | 2 ++
templates/files/file_list.html | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/files/views.py b/files/views.py
index 939f81e..c299971 100644
--- a/files/views.py
+++ b/files/views.py
@@ -14,6 +14,7 @@
from files.filters import FileFilter
from files.models import (
File,
+ default_licence,
)
from files.forms import (
FileForm,
@@ -36,6 +37,7 @@ def get_context_data(self, **kwargs):
"""
context = super(FileList, self).get_context_data(**kwargs)
context["unknown_licences"] = File.objects.filter(licence__name="Unknown").count()
+ context["unknown_licence_id"] = default_licence()
return context
diff --git a/templates/files/file_list.html b/templates/files/file_list.html
index 344fb53..dc0290b 100644
--- a/templates/files/file_list.html
+++ b/templates/files/file_list.html
@@ -31,7 +31,7 @@
{% if unknown_licences %}
{% endif %}
From 95e2d0fe1b85f593fc563dee7c682bc829120d32 Mon Sep 17 00:00:00 2001
From: Jack Morgan
Date: Thu, 7 Jun 2018 12:11:17 +1200
Subject: [PATCH 57/72] Load files from loader
---
.travis.yml | 2 +-
files/content/files.yaml | 4 +++
files/content/licences.yaml | 9 ++++--
files/management/commands/_FileLoader.py | 30 +++++++++++++++++++
files/management/commands/_LicenceLoader.py | 5 ++--
.../{loadlicences.py => loadfiles.py} | 8 +++--
files/migrations/0002_licence_slug.py | 19 ++++++++++++
files/models.py | 4 ++-
release.sh | 2 +-
9 files changed, 72 insertions(+), 11 deletions(-)
create mode 100644 files/content/files.yaml
create mode 100644 files/management/commands/_FileLoader.py
rename files/management/commands/{loadlicences.py => loadfiles.py} (54%)
create mode 100644 files/migrations/0002_licence_slug.py
diff --git a/.travis.yml b/.travis.yml
index 2b39e2d..cb764d8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,7 +14,7 @@ jobs:
- stage: test
script: coverage run --rcfile=.coveragerc manage.py test tests --settings=config.settings.testing -v=3
- script: python manage.py loadpikau
- - script: python manage.py loadlicences
+ - script: python manage.py loadfiles
- script: flake8
- script: pydocstyle --count --explain
after_success:
diff --git a/files/content/files.yaml b/files/content/files.yaml
new file mode 100644
index 0000000..053a566
--- /dev/null
+++ b/files/content/files.yaml
@@ -0,0 +1,4 @@
+banner-mahuika-maui-png:
+ filename: "banner-mahuika-maui.png"
+ location: "https://drive.google.com/open?id=1NJfnUmj6et78-o8Eov2i7fgZdauR_myE"
+ licence: unknown
diff --git a/files/content/licences.yaml b/files/content/licences.yaml
index ee092c3..3a58ee5 100644
--- a/files/content/licences.yaml
+++ b/files/content/licences.yaml
@@ -1,6 +1,9 @@
-- name: "Unknown"
+unknown:
+ name: "Unknown"
url: "https://creativecommons.org/choose/"
-- name: "Creative Commons (BY-SA 4.0)"
+cc-by-sa-4:
+ name: "Creative Commons (BY-SA 4.0)"
url: "https://creativecommons.org/licenses/by-sa/4.0/"
-- name: "Creative Commons (BY-NC-SA 4.0)"
+cc-by-nc-sa-4:
+ name: "Creative Commons (BY-NC-SA 4.0)"
url: "https://creativecommons.org/licenses/by-nc-sa/4.0/"
diff --git a/files/management/commands/_FileLoader.py b/files/management/commands/_FileLoader.py
new file mode 100644
index 0000000..d9a67b0
--- /dev/null
+++ b/files/management/commands/_FileLoader.py
@@ -0,0 +1,30 @@
+"""Custom loader for loading files."""
+
+from django.db import transaction
+from files.models import File, Licence
+from utils.BaseLoader import BaseLoader
+
+
+class FileLoader(BaseLoader):
+ """Custom loader for loading files."""
+
+ @transaction.atomic
+ def load(self):
+ """Load the files into the database."""
+ files = self.load_yaml_file("files.yaml")
+
+ for file_slug, file_data in files.items():
+ licence = Licence.objects.get(slug=file_data.get("licence", "unknown"))
+ defaults = {
+ "filename": file_data["filename"],
+ "location": file_data["location"],
+ "licence": licence,
+ "description": file_data.get("description", ""),
+ }
+ file_object, created = File.objects.update_or_create(
+ slug=file_slug,
+ defaults=defaults,
+ )
+ self.log_object_creation(created, file_object)
+
+ self.log("All files loaded!\n")
diff --git a/files/management/commands/_LicenceLoader.py b/files/management/commands/_LicenceLoader.py
index 14e2dfe..1668521 100644
--- a/files/management/commands/_LicenceLoader.py
+++ b/files/management/commands/_LicenceLoader.py
@@ -13,12 +13,13 @@ def load(self):
"""Load the licences into the database."""
licences = self.load_yaml_file("licences.yaml")
- for licence_data in licences:
+ for licence_slug, licence_data in licences.items():
defaults = {
+ "name": licence_data["name"],
"url": licence_data["url"],
}
licence, created = Licence.objects.update_or_create(
- name=licence_data["name"],
+ slug=licence_slug,
defaults=defaults,
)
self.log_object_creation(created, licence)
diff --git a/files/management/commands/loadlicences.py b/files/management/commands/loadfiles.py
similarity index 54%
rename from files/management/commands/loadlicences.py
rename to files/management/commands/loadfiles.py
index 1733050..2130a8a 100644
--- a/files/management/commands/loadlicences.py
+++ b/files/management/commands/loadfiles.py
@@ -1,16 +1,18 @@
-"""Module for the custom Django loadlicences command."""
+"""Module for the custom Django loadfiles command."""
from django.conf import settings
from django.core import management
from files.management.commands._LicenceLoader import LicenceLoader
+from files.management.commands._FileLoader import FileLoader
class Command(management.base.BaseCommand):
- """Required command class for the custom Django loadlicences command."""
+ """Required command class for the custom Django loadfiles command."""
help = "Loads licences into the website"
def handle(self, *args, **options):
- """Automatically called when the loadlicences command is given."""
+ """Automatically called when the loadfiles command is given."""
base_path = settings.FILES_CONTENT_BASE_PATH
LicenceLoader(base_path).load()
+ FileLoader(base_path).load()
diff --git a/files/migrations/0002_licence_slug.py b/files/migrations/0002_licence_slug.py
new file mode 100644
index 0000000..ffcb8fe
--- /dev/null
+++ b/files/migrations/0002_licence_slug.py
@@ -0,0 +1,19 @@
+# Generated by Django 2.0.5 on 2018-06-06 23:48
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('files', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='licence',
+ name='slug',
+ field=models.SlugField(default='', unique=True),
+ preserve_default=False,
+ ),
+ ]
diff --git a/files/models.py b/files/models.py
index eb0a2a7..3a8f8ec 100644
--- a/files/models.py
+++ b/files/models.py
@@ -3,6 +3,7 @@
from django.db import models
from django.core.exceptions import ObjectDoesNotExist
from django.urls import reverse
+from django.utils.text import slugify
def default_licence():
@@ -12,7 +13,7 @@ def default_licence():
Licence 'Unknown' if available, otherwise None.
"""
try:
- default = Licence.objects.get(name="Unknown").pk
+ default = Licence.objects.get(slug="unknown").pk
except ObjectDoesNotExist:
default = None
return default
@@ -21,6 +22,7 @@ def default_licence():
class Licence(models.Model):
"""Model for licence."""
+ slug = models.SlugField(unique=True)
name = models.CharField(max_length=200, unique=True)
url = models.URLField()
diff --git a/release.sh b/release.sh
index 23a0bba..2e9378d 100755
--- a/release.sh
+++ b/release.sh
@@ -1,5 +1,5 @@
#!/bin/bash
python manage.py collectstatic --no-input --settings=config.settings.production
python manage.py migrate --no-input --settings=config.settings.production
-python manage.py loadlicences --settings=config.settings.production
+python manage.py loadfiles --settings=config.settings.production
python manage.py loadpikau --settings=config.settings.production
From 051104a9bbba05888548527e7fd9032000fde3eb Mon Sep 17 00:00:00 2001
From: Jack Morgan
Date: Thu, 7 Jun 2018 14:05:07 +1200
Subject: [PATCH 58/72] =?UTF-8?q?Check=20files=20used=20within=20p=C4=ABka?=
=?UTF-8?q?u?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Also store name of files
---
.travis.yml | 3 +-
files/content/files.yaml | 40 ++++++++++++++++++-
files/management/commands/_FileLoader.py | 1 +
files/migrations/0003_auto_20180607_1232.py | 23 +++++++++++
files/migrations/0004_file_name.py | 19 +++++++++
files/models.py | 7 ++--
files/tables.py | 6 +--
.../metadata.yaml | 5 +++
.../management/commands/_PikauCourseLoader.py | 22 +++++++++-
pikau/management/commands/loaddata.py | 14 +++++++
pikau/migrations/0031_pikaucourse_files.py | 19 +++++++++
pikau/models.py | 8 +++-
pikau/utils/find_file.py | 29 ++++++++++++++
release.sh | 3 +-
14 files changed, 185 insertions(+), 14 deletions(-)
create mode 100644 files/migrations/0003_auto_20180607_1232.py
create mode 100644 files/migrations/0004_file_name.py
create mode 100644 pikau/management/commands/loaddata.py
create mode 100644 pikau/migrations/0031_pikaucourse_files.py
create mode 100644 pikau/utils/find_file.py
diff --git a/.travis.yml b/.travis.yml
index cb764d8..b637672 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,8 +13,7 @@ jobs:
include:
- stage: test
script: coverage run --rcfile=.coveragerc manage.py test tests --settings=config.settings.testing -v=3
- - script: python manage.py loadpikau
- - script: python manage.py loadfiles
+ - script: python manage.py loaddata
- script: flake8
- script: pydocstyle --count --explain
after_success:
diff --git a/files/content/files.yaml b/files/content/files.yaml
index 053a566..9a93201 100644
--- a/files/content/files.yaml
+++ b/files/content/files.yaml
@@ -1,4 +1,42 @@
banner-mahuika-maui-png:
+ name: "Mahuika and Māui Banner"
filename: "banner-mahuika-maui.png"
location: "https://drive.google.com/open?id=1NJfnUmj6et78-o8Eov2i7fgZdauR_myE"
- licence: unknown
+maui-face-png:
+ name: "Māui face"
+ filename: "maui-face.png"
+ location: "https://drive.google.com/open?id=1NU2glbUDS928aBwKgivX4GdoyKKkbMmo"
+mahuika-face-png:
+ name: "Mahuika face"
+ filename: "mahuika-face.png"
+ location: "https://drive.google.com/open?id=1396r4RQjZxZdyAPVzDm3o0heDJit1m_E"
+what-is-ct-png:
+ name: "What is CT?"
+ filename: "what-is-ct.png"
+ location: "images/pikau/what-is-ct.png"
+ licence: cc-by-sa-4
+ct-around-the-world-png:
+ name: "CT around the world"
+ filename: "ct-around-the-world.png"
+ location: "images/pikau/ct-around-the-world.png"
+ licence: cc-by-sa-4
+placeholder-video:
+ name: "Kia Takatū ā-Matihiko Placeholder Video"
+ filename: "https://www.youtube.com/embed/zSfzB-Z-mKM"
+ location: "https://www.youtube.com/embed/zSfzB-Z-mKM"
+ licence: cc-by-sa-4
+ct-loading-planes-trimmed:
+ name: "CT Loading Planes - Trimmed"
+ filename: "CT loading planes trimmed.mov"
+ location: "https://vimeo.com/273809039/eb5cb42933"
+ licence: cc-by-sa-4
+ct-six-elements-of-digital-devices:
+ name: "Six elements of digital devices"
+ filename: "six elements of digital devices.mp4"
+ location: "https://vimeo.com/273813250/f251e2a3d4"
+ licence: cc-by-sa-4
+csfg-algorithms-trailer:
+ name: "Computer Science Field Guide: Algorithms"
+ filename: "Computer Science Field Guide - Algorithms.mp4"
+ location: "https://vimeo.com/69609500"
+ licence: cc-by-sa-4
diff --git a/files/management/commands/_FileLoader.py b/files/management/commands/_FileLoader.py
index d9a67b0..f605fec 100644
--- a/files/management/commands/_FileLoader.py
+++ b/files/management/commands/_FileLoader.py
@@ -16,6 +16,7 @@ def load(self):
for file_slug, file_data in files.items():
licence = Licence.objects.get(slug=file_data.get("licence", "unknown"))
defaults = {
+ "name": file_data["name"],
"filename": file_data["filename"],
"location": file_data["location"],
"licence": licence,
diff --git a/files/migrations/0003_auto_20180607_1232.py b/files/migrations/0003_auto_20180607_1232.py
new file mode 100644
index 0000000..f45d1a5
--- /dev/null
+++ b/files/migrations/0003_auto_20180607_1232.py
@@ -0,0 +1,23 @@
+# Generated by Django 2.0.5 on 2018-06-07 00:32
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('files', '0002_licence_slug'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='file',
+ name='filename',
+ field=models.CharField(max_length=200, unique=True),
+ ),
+ migrations.AlterField(
+ model_name='file',
+ name='location',
+ field=models.URLField(unique=True),
+ ),
+ ]
diff --git a/files/migrations/0004_file_name.py b/files/migrations/0004_file_name.py
new file mode 100644
index 0000000..3b4f9b3
--- /dev/null
+++ b/files/migrations/0004_file_name.py
@@ -0,0 +1,19 @@
+# Generated by Django 2.0.5 on 2018-06-07 02:00
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('files', '0003_auto_20180607_1232'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='file',
+ name='name',
+ field=models.CharField(default='', max_length=200, unique=True),
+ preserve_default=False,
+ ),
+ ]
diff --git a/files/models.py b/files/models.py
index 3a8f8ec..a2350b5 100644
--- a/files/models.py
+++ b/files/models.py
@@ -52,9 +52,10 @@ class File(models.Model):
"""Model for file."""
slug = models.SlugField(unique=True)
- filename = models.CharField(max_length=200)
+ name = models.CharField(max_length=200, unique=True)
+ filename = models.CharField(max_length=200, unique=True)
description = models.TextField(blank=True)
- location = models.URLField()
+ location = models.URLField(unique=True)
licence = models.ForeignKey(
Licence,
on_delete=models.CASCADE,
@@ -77,7 +78,7 @@ def __str__(self):
Returns:
String describing file.
"""
- return self.filename
+ return self.name
def __repr__(self):
"""Text representation of File object for developers.
diff --git a/files/tables.py b/files/tables.py
index 53bb4ad..0505aab 100644
--- a/files/tables.py
+++ b/files/tables.py
@@ -9,12 +9,12 @@
class FileTable(tables.Table):
"""Table to display all files."""
- filename = tables.LinkColumn()
+ name = tables.LinkColumn()
licence = tables.RelatedLinkColumn()
class Meta:
"""Meta attributes for FileTable class."""
model = File
- fields = ("filename", "licence")
- order_by = "filename"
+ fields = ("name", "licence")
+ order_by = "name"
diff --git a/pikau/content/pikau-courses/what-is-computational-thinking/metadata.yaml b/pikau/content/pikau-courses/what-is-computational-thinking/metadata.yaml
index 29ee69c..3a53323 100644
--- a/pikau/content/pikau-courses/what-is-computational-thinking/metadata.yaml
+++ b/pikau/content/pikau-courses/what-is-computational-thinking/metadata.yaml
@@ -24,3 +24,8 @@ content:
- slug: references
file: references.md
assessment-items: assessment-items.md
+
+extra-files:
+ - ct-loading-planes-trimmed
+ - csfg-algorithms-trailer
+ - ct-six-elements-of-digital-devices
diff --git a/pikau/management/commands/_PikauCourseLoader.py b/pikau/management/commands/_PikauCourseLoader.py
index 2869b62..3bc3553 100644
--- a/pikau/management/commands/_PikauCourseLoader.py
+++ b/pikau/management/commands/_PikauCourseLoader.py
@@ -3,6 +3,7 @@
import os.path
from django.db import transaction
from utils.BaseLoader import BaseLoader
+from pikau.utils.find_file import find_file
from pikau.models import (
PikauCourse,
PikauUnit,
@@ -12,6 +13,7 @@
GlossaryTerm,
ProgressOutcome,
)
+from files.models import File
CONFIG_FILE = "pikau-courses.yaml"
COVER_PHOTO_DEFAULT = "images/core-education/pikau-course-cover.png"
@@ -62,14 +64,17 @@ def load(self):
remove_title=False,
).html_string
+ cover_photo = pikau_course_metadata.get("cover-photo", COVER_PHOTO_DEFAULT)
+ trailer_video = pikau_course_metadata.get("trailer-video", "")
+
defaults = {
"name": pikau_course_metadata["name"],
"status": pikau_course_metadata["status"],
"language": pikau_course_metadata["language"],
"topic": Topic.objects.get(slug=pikau_course_metadata["topic"]),
"level": Level.objects.get(slug=pikau_course_metadata["level"]),
- "trailer_video": pikau_course_metadata.get("trailer-video", ""),
- "cover_photo": pikau_course_metadata.get("cover-photo", COVER_PHOTO_DEFAULT),
+ "trailer_video": trailer_video,
+ "cover_photo": cover_photo,
"overview": pikau_course_overview,
"readiness_level": pikau_course_metadata.get("readiness-level"),
"study_plan": pikau_course_study_plan,
@@ -82,6 +87,14 @@ def load(self):
defaults=defaults,
)
+ # Check cover photo, trailer video, and extra files are logged
+ pikau_course.files.add(find_file(filename=cover_photo))
+ if trailer_video:
+ pikau_course.files.add(find_file(filename=trailer_video))
+ for file_slug in pikau_course_metadata.get("extra-files", list()):
+ pikau_course.files.add(find_file(slug=file_slug))
+
+
# Delete all existing units for course
# since the will be loaded from raw data.
PikauUnit.objects.filter(pikau_course=pikau_course).delete()
@@ -92,6 +105,11 @@ def load(self):
heading_required=True,
remove_title=True,
)
+ print(unit_content.required_files["images"])
+ # Check files in content
+ for filename in unit_content.required_files["images"]:
+ pikau_course.files.add(find_file(filename=filename))
+
pikau_course.content.create(
slug=unit_data["slug"],
pikau_course=pikau_course,
diff --git a/pikau/management/commands/loaddata.py b/pikau/management/commands/loaddata.py
new file mode 100644
index 0000000..a572b90
--- /dev/null
+++ b/pikau/management/commands/loaddata.py
@@ -0,0 +1,14 @@
+"""Module for the custom Django loaddata command."""
+
+from django.core import management
+
+
+class Command(management.base.BaseCommand):
+ """Required command class for the custom Django loaddata command."""
+
+ help = "Update all data from content folders for all applications"
+
+ def handle(self, *args, **options):
+ """Automatically called when the updatedata command is given."""
+ management.call_command("loadfiles")
+ management.call_command("loadpikau")
diff --git a/pikau/migrations/0031_pikaucourse_files.py b/pikau/migrations/0031_pikaucourse_files.py
new file mode 100644
index 0000000..3f04749
--- /dev/null
+++ b/pikau/migrations/0031_pikaucourse_files.py
@@ -0,0 +1,19 @@
+# Generated by Django 2.0.5 on 2018-06-07 00:28
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('files', '0002_licence_slug'),
+ ('pikau', '0030_auto_20180529_0956'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='pikaucourse',
+ name='files',
+ field=models.ManyToManyField(blank=True, related_name='pikau_courses', to='files.File'),
+ ),
+ ]
diff --git a/pikau/models.py b/pikau/models.py
index 8342ccd..3a52cb6 100644
--- a/pikau/models.py
+++ b/pikau/models.py
@@ -5,6 +5,8 @@
from django.contrib.auth.models import User
from django.template import defaultfilters
from django.urls import reverse
+from files.models import File
+
LANGUAGE_CHOICES = (
("en", "English"),
@@ -242,7 +244,11 @@ class PikauCourse(models.Model):
study_plan = models.TextField(blank=True)
assessment_description = models.TextField(blank=True)
assessment_items = models.TextField(blank=True)
- # TODO: Add resources
+ files = models.ManyToManyField(
+ File,
+ related_name="pikau_courses",
+ blank=True,
+ )
# Development attributes
development_folder = models.URLField(blank=True)
diff --git a/pikau/utils/find_file.py b/pikau/utils/find_file.py
new file mode 100644
index 0000000..f1180ab
--- /dev/null
+++ b/pikau/utils/find_file.py
@@ -0,0 +1,29 @@
+""""""
+
+from os.path import basename
+from django.core.exceptions import ObjectDoesNotExist
+from django.urls import reverse
+from files.models import File
+
+
+def find_file(filename=None, slug=None):
+ if not filename and not slug:
+ raise ValueError("One keyword argument is required: filename or slug")
+ try:
+ if filename:
+ file_object = File.objects.get(filename=filename)
+ else:
+ file_object = File.objects.get(slug=slug)
+ except ObjectDoesNotExist:
+ if filename and not filename.startswith("http"):
+ try:
+ filename = basename(filename)
+ file_object = File.objects.get(filename=filename)
+ except ObjectDoesNotExist:
+ file_object = None
+ else:
+ file_object = None
+ if not file_object:
+ raise ValueError("File '{}' not listed in files list".format(filename or slug))
+ else:
+ return file_object
diff --git a/release.sh b/release.sh
index 2e9378d..b86601d 100755
--- a/release.sh
+++ b/release.sh
@@ -1,5 +1,4 @@
#!/bin/bash
python manage.py collectstatic --no-input --settings=config.settings.production
python manage.py migrate --no-input --settings=config.settings.production
-python manage.py loadfiles --settings=config.settings.production
-python manage.py loadpikau --settings=config.settings.production
+python manage.py loaddata --settings=config.settings.production
From c525939f77b1dedb2a97bc0273dff1f163ab83c5 Mon Sep 17 00:00:00 2001
From: Jack Morgan
Date: Thu, 7 Jun 2018 14:07:47 +1200
Subject: [PATCH 59/72] Style fixes
---
files/models.py | 1 -
pikau/management/commands/_PikauCourseLoader.py | 2 --
pikau/utils/find_file.py | 15 +++++++++++++--
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/files/models.py b/files/models.py
index a2350b5..0fca87b 100644
--- a/files/models.py
+++ b/files/models.py
@@ -3,7 +3,6 @@
from django.db import models
from django.core.exceptions import ObjectDoesNotExist
from django.urls import reverse
-from django.utils.text import slugify
def default_licence():
diff --git a/pikau/management/commands/_PikauCourseLoader.py b/pikau/management/commands/_PikauCourseLoader.py
index 3bc3553..907c374 100644
--- a/pikau/management/commands/_PikauCourseLoader.py
+++ b/pikau/management/commands/_PikauCourseLoader.py
@@ -13,7 +13,6 @@
GlossaryTerm,
ProgressOutcome,
)
-from files.models import File
CONFIG_FILE = "pikau-courses.yaml"
COVER_PHOTO_DEFAULT = "images/core-education/pikau-course-cover.png"
@@ -94,7 +93,6 @@ def load(self):
for file_slug in pikau_course_metadata.get("extra-files", list()):
pikau_course.files.add(find_file(slug=file_slug))
-
# Delete all existing units for course
# since the will be loaded from raw data.
PikauUnit.objects.filter(pikau_course=pikau_course).delete()
diff --git a/pikau/utils/find_file.py b/pikau/utils/find_file.py
index f1180ab..f106214 100644
--- a/pikau/utils/find_file.py
+++ b/pikau/utils/find_file.py
@@ -1,12 +1,23 @@
-""""""
+"""Find file object for given filename or slug."""
from os.path import basename
from django.core.exceptions import ObjectDoesNotExist
-from django.urls import reverse
from files.models import File
def find_file(filename=None, slug=None):
+ """Find file object for given filename or slug.
+
+ Args:
+ filename (str): String of file filename.
+ slug (str): String of file slug.
+
+ Returns:
+ File object.
+
+ Raises:
+ ValueError: If file object cannot be found.
+ """
if not filename and not slug:
raise ValueError("One keyword argument is required: filename or slug")
try:
From ae5e545e38a66ccf9194a0c8f3c4178b49abfc76 Mon Sep 17 00:00:00 2001
From: Jack Morgan
Date: Thu, 7 Jun 2018 14:33:39 +1200
Subject: [PATCH 60/72] =?UTF-8?q?Display=20links=20between=20files=20and?=
=?UTF-8?q?=20p=C4=ABkau=20(fixes=20#61)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
templates/files/file_detail.html | 14 +++++++++++---
templates/pikau/glossaryterm_detail.html | 2 +-
templates/pikau/pikaucourse_detail.html | 13 ++++++++++++-
3 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/templates/files/file_detail.html b/templates/files/file_detail.html
index 801c986..34bb350 100644
--- a/templates/files/file_detail.html
+++ b/templates/files/file_detail.html
@@ -9,21 +9,29 @@
{% endblock breadcrumbs %}
{% block page_heading %}
- File: {{ file.filename }}
{% with text='Update file' %}
{% url 'files:file_update' file.slug as update_url %}
{% include "snippets/update_button.html" %}
{% endwith %}
+ File:
+ {{ file.name }}
{% endblock page_heading %}
{% block content %}
- {{ file.location }}
+ {{ file.filename }}
- {{ file.licence.name }}
+ Licence: {{ file.licence.name }}
{{ file.description }}
Slug: {{ file.slug }}
+
+ Pīkau courses: {{ file.pikau_courses.count }}
+
+ {% for pikau_course in file.pikau_courses.all %}
+ {% include "pikau/snippets/pikau_course_card.html" %}
+ {% endfor %}
+
{% endblock content %}
diff --git a/templates/pikau/glossaryterm_detail.html b/templates/pikau/glossaryterm_detail.html
index 3bebb24..395ccd3 100644
--- a/templates/pikau/glossaryterm_detail.html
+++ b/templates/pikau/glossaryterm_detail.html
@@ -25,7 +25,7 @@
Pikau Courses: {{ glossaryterm.pikau_courses.count }}
- {% for pikau_course in level.pikau_courses.all %}
+ {% for pikau_course in glossaryterm.pikau_courses.all %}
{% include "pikau/snippets/pikau_course_card.html" %}
{% endfor %}
diff --git a/templates/pikau/pikaucourse_detail.html b/templates/pikau/pikaucourse_detail.html
index d5d2a7b..4b59302 100644
--- a/templates/pikau/pikaucourse_detail.html
+++ b/templates/pikau/pikaucourse_detail.html
@@ -35,7 +35,6 @@ {{ pikau_course.name }}
{% endblock custom_page_heading %}
{% block content %}
-
Development Information
@@ -184,6 +183,18 @@
Trailer Video
View
{% endif %}
+ {% if pikau_course.files %}
+
Files
+
+
+ {% for file in pikau_course.files.all %}
+ -
+ {{ file.name }}
+
+ {% endfor %}
+
+ {% endif %}
+
{% if pikau_course.resources %}
Resources
TODO RENDERING
From 77fb37a09670241bb9fc318097765bd4c4c17809 Mon Sep 17 00:00:00 2001
From: Jack Morgan
Date: Thu, 7 Jun 2018 14:56:12 +1200
Subject: [PATCH 61/72] Recreate file migrations
This will require a database wipe
---
files/migrations/0001_initial.py | 8 ++++---
files/migrations/0002_licence_slug.py | 19 -----------------
files/migrations/0003_auto_20180607_1232.py | 23 ---------------------
files/migrations/0004_file_name.py | 19 -----------------
pikau/migrations/0031_pikaucourse_files.py | 4 ++--
5 files changed, 7 insertions(+), 66 deletions(-)
delete mode 100644 files/migrations/0002_licence_slug.py
delete mode 100644 files/migrations/0003_auto_20180607_1232.py
delete mode 100644 files/migrations/0004_file_name.py
diff --git a/files/migrations/0001_initial.py b/files/migrations/0001_initial.py
index 2db3918..b005ff9 100644
--- a/files/migrations/0001_initial.py
+++ b/files/migrations/0001_initial.py
@@ -1,4 +1,4 @@
-# Generated by Django 2.0.5 on 2018-05-21 04:19
+# Generated by Django 2.0.5 on 2018-06-07 02:53
from django.db import migrations, models
import django.db.models.deletion
@@ -18,15 +18,17 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('slug', models.SlugField(unique=True)),
- ('filename', models.CharField(max_length=200)),
+ ('name', models.CharField(max_length=200, unique=True)),
+ ('filename', models.CharField(max_length=200, unique=True)),
('description', models.TextField(blank=True)),
- ('location', models.URLField()),
+ ('location', models.URLField(unique=True)),
],
),
migrations.CreateModel(
name='Licence',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('slug', models.SlugField(unique=True)),
('name', models.CharField(max_length=200, unique=True)),
('url', models.URLField()),
],
diff --git a/files/migrations/0002_licence_slug.py b/files/migrations/0002_licence_slug.py
deleted file mode 100644
index ffcb8fe..0000000
--- a/files/migrations/0002_licence_slug.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Generated by Django 2.0.5 on 2018-06-06 23:48
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('files', '0001_initial'),
- ]
-
- operations = [
- migrations.AddField(
- model_name='licence',
- name='slug',
- field=models.SlugField(default='', unique=True),
- preserve_default=False,
- ),
- ]
diff --git a/files/migrations/0003_auto_20180607_1232.py b/files/migrations/0003_auto_20180607_1232.py
deleted file mode 100644
index f45d1a5..0000000
--- a/files/migrations/0003_auto_20180607_1232.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# Generated by Django 2.0.5 on 2018-06-07 00:32
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('files', '0002_licence_slug'),
- ]
-
- operations = [
- migrations.AlterField(
- model_name='file',
- name='filename',
- field=models.CharField(max_length=200, unique=True),
- ),
- migrations.AlterField(
- model_name='file',
- name='location',
- field=models.URLField(unique=True),
- ),
- ]
diff --git a/files/migrations/0004_file_name.py b/files/migrations/0004_file_name.py
deleted file mode 100644
index 3b4f9b3..0000000
--- a/files/migrations/0004_file_name.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Generated by Django 2.0.5 on 2018-06-07 02:00
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('files', '0003_auto_20180607_1232'),
- ]
-
- operations = [
- migrations.AddField(
- model_name='file',
- name='name',
- field=models.CharField(default='', max_length=200, unique=True),
- preserve_default=False,
- ),
- ]
diff --git a/pikau/migrations/0031_pikaucourse_files.py b/pikau/migrations/0031_pikaucourse_files.py
index 3f04749..af55bb2 100644
--- a/pikau/migrations/0031_pikaucourse_files.py
+++ b/pikau/migrations/0031_pikaucourse_files.py
@@ -1,4 +1,4 @@
-# Generated by Django 2.0.5 on 2018-06-07 00:28
+# Generated by Django 2.0.5 on 2018-06-07 02:53
from django.db import migrations, models
@@ -6,7 +6,7 @@
class Migration(migrations.Migration):
dependencies = [
- ('files', '0002_licence_slug'),
+ ('files', '0001_initial'),
('pikau', '0030_auto_20180529_0956'),
]
From 3ce469d216ed77882a292f3215d6d0cbe3d05778 Mon Sep 17 00:00:00 2001
From: Jack Morgan
Date: Thu, 7 Jun 2018 15:04:43 +1200
Subject: [PATCH 62/72] Update tests
---
tests/files/FileTestDataGenerator.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tests/files/FileTestDataGenerator.py b/tests/files/FileTestDataGenerator.py
index 586a649..b687543 100644
--- a/tests/files/FileTestDataGenerator.py
+++ b/tests/files/FileTestDataGenerator.py
@@ -27,9 +27,10 @@ def create_file(self, number, licence=None):
"""
file_object = File(
slug="file-{}".format(number),
- filename="File {}".format(number),
+ name="File {}".format(number),
+ filename="file-{}.ext".format(number),
description="Description for file {}".format(number),
- location="https://www.example.com",
+ location="https://www.example.com/{}".format(number),
)
file_object.save()
if licence:
@@ -46,6 +47,7 @@ def create_licence(self, number):
File object.
"""
licence = Licence(
+ slug="licence-{}".format(number),
name="Licence {}".format(number),
url="https://www.example.com/licence-{}".format(number),
)
From 6ab65b8a56df19de582da1953e5dd831c56603c0 Mon Sep 17 00:00:00 2001
From: Jack Morgan
Date: Thu, 7 Jun 2018 16:14:31 +1200
Subject: [PATCH 63/72] =?UTF-8?q?(WIP)=20Adding=20"Why=20DT=3F"=20p=C4=ABk?=
=?UTF-8?q?au?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
files/content/files.yaml | 19 +++++++++
pikau/content/pikau-courses.yaml | 1 +
.../metadata.yaml | 1 +
.../assessment-items.md | 14 ++++++
.../why-digital-technologies/metadata.yaml | 29 +++++++++++++
.../why-digital-technologies/overview.md | 5 +++
.../why-this-matters/already-know-this.md | 36 ++++++++++++++++
.../how-are-students-better-off.md | 29 +++++++++++++
.../is-it-all-about-devices.md | 40 ++++++++++++++++++
.../why-this-matters/users-or-creators.md | 10 +++++
.../why-digital-technologies/wrapping-up.md | 5 +++
pikau/content/topics.yaml | 1 +
.../management/commands/_PikauCourseLoader.py | 1 -
.../images/pikau/arnold-the-wonder-parrot.jpg | Bin 0 -> 306527 bytes
.../pikau/information-theory-activity.jpg | Bin 0 -> 1730909 bytes
15 files changed, 190 insertions(+), 1 deletion(-)
create mode 100644 pikau/content/pikau-courses/why-digital-technologies/assessment-items.md
create mode 100644 pikau/content/pikau-courses/why-digital-technologies/metadata.yaml
create mode 100644 pikau/content/pikau-courses/why-digital-technologies/overview.md
create mode 100644 pikau/content/pikau-courses/why-digital-technologies/why-this-matters/already-know-this.md
create mode 100644 pikau/content/pikau-courses/why-digital-technologies/why-this-matters/how-are-students-better-off.md
create mode 100644 pikau/content/pikau-courses/why-digital-technologies/why-this-matters/is-it-all-about-devices.md
create mode 100644 pikau/content/pikau-courses/why-digital-technologies/why-this-matters/users-or-creators.md
create mode 100644 pikau/content/pikau-courses/why-digital-technologies/wrapping-up.md
create mode 100644 static/images/pikau/arnold-the-wonder-parrot.jpg
create mode 100644 static/images/pikau/information-theory-activity.jpg
diff --git a/files/content/files.yaml b/files/content/files.yaml
index 9a93201..462dd7d 100644
--- a/files/content/files.yaml
+++ b/files/content/files.yaml
@@ -20,6 +20,16 @@ ct-around-the-world-png:
filename: "ct-around-the-world.png"
location: "images/pikau/ct-around-the-world.png"
licence: cc-by-sa-4
+arnold-the-wonder-parrot-jpg:
+ name: "Arnold the Wonder Parrot"
+ filename: "arnold-the-wonder-parrot.jpg"
+ location: "images/pikau/arnold-the-wonder-parrot.jpg"
+ licence: cc-by-sa-4
+information-theory-activity:
+ name: "Information Theory CS Unplugged Activity"
+ filename: "information-theory-activity.jpg"
+ location: "images/pikau/information-theory-activity.jpg"
+ licence: cc-by-sa-4
placeholder-video:
name: "Kia Takatū ā-Matihiko Placeholder Video"
filename: "https://www.youtube.com/embed/zSfzB-Z-mKM"
@@ -35,8 +45,17 @@ ct-six-elements-of-digital-devices:
filename: "six elements of digital devices.mp4"
location: "https://vimeo.com/273813250/f251e2a3d4"
licence: cc-by-sa-4
+digital-images:
+ name: "Digital images"
+ filename: "digital images.mp4"
+ location: "https://vimeo.com/273824548/770c5c1c48"
+ licence: cc-by-sa-4
csfg-algorithms-trailer:
name: "Computer Science Field Guide: Algorithms"
filename: "Computer Science Field Guide - Algorithms.mp4"
location: "https://vimeo.com/69609500"
licence: cc-by-sa-4
+getting-the-most-out-of-pikau:
+ name: Getting the most out of pīkau
+ filename: https://vimeo.com/272882311/8e4cf1de3f
+ location: https://vimeo.com/272882311/8e4cf1de3f
diff --git a/pikau/content/pikau-courses.yaml b/pikau/content/pikau-courses.yaml
index 6dd21c4..d3f0515 100644
--- a/pikau/content/pikau-courses.yaml
+++ b/pikau/content/pikau-courses.yaml
@@ -1,4 +1,5 @@
courses:
- getting-the-most-out-of-pikau
+ - why-digital-technologies
- what-is-computational-thinking
- computational-thinking-the-international-perspective
diff --git a/pikau/content/pikau-courses/getting-the-most-out-of-pikau/metadata.yaml b/pikau/content/pikau-courses/getting-the-most-out-of-pikau/metadata.yaml
index 5ee6ce8..b7705aa 100644
--- a/pikau/content/pikau-courses/getting-the-most-out-of-pikau/metadata.yaml
+++ b/pikau/content/pikau-courses/getting-the-most-out-of-pikau/metadata.yaml
@@ -8,6 +8,7 @@ level: all
tags:
- introductory
cover-photo: images/core-education/banner-mahuika-maui.png
+trailer-video: https://vimeo.com/272882311/8e4cf1de3f
content:
- slug: introduction-to-pikau
file: introduction-to-pikau.md
diff --git a/pikau/content/pikau-courses/why-digital-technologies/assessment-items.md b/pikau/content/pikau-courses/why-digital-technologies/assessment-items.md
new file mode 100644
index 0000000..24db32a
--- /dev/null
+++ b/pikau/content/pikau-courses/why-digital-technologies/assessment-items.md
@@ -0,0 +1,14 @@
+# Assessment 1: Multiple Choice
+
+### What is the key reason to teach Computational Thinking?
+
+a) So students think like a computer.
+b) So students learn how to think in ways that are useful for understanding and programming digital devices. [correct]
+c) So students learn that computational thinking is what all devices do.
+d) So students have a framework that applies to all of STEM.
+
+# Assessment 2: Open Response
+
+### What aspects of computational thinking do I recognise in what I am already teaching? Give one example.
+
+This could link to Ngā Kiriahi, the communities of practice.
diff --git a/pikau/content/pikau-courses/why-digital-technologies/metadata.yaml b/pikau/content/pikau-courses/why-digital-technologies/metadata.yaml
new file mode 100644
index 0000000..45c9e00
--- /dev/null
+++ b/pikau/content/pikau-courses/why-digital-technologies/metadata.yaml
@@ -0,0 +1,29 @@
+name: "Why digital technologies?"
+status: 5
+language: en
+topic: general
+level: all
+tags:
+ - introductory
+cover-photo: images/pikau/information-theory-activity.jpg
+trailer-video: https://www.youtube.com/embed/zSfzB-Z-mKM
+
+overview: overview.md
+content:
+ - slug: users-or-creators
+ file: why-this-matters/users-or-creators.md
+ module: Why this matters...
+ - slug: already-know-this
+ file: why-this-matters/already-know-this.md
+ module: Why this matters...
+ - slug: how-are-students-better-off
+ file: why-this-matters/how-are-students-better-off.md
+ module: Why this matters...
+ - slug: is-it-all-about-devices
+ file: why-this-matters/is-it-all-about-devices.md
+ module: Why this matters...
+ - slug: wrapping-up
+ file: wrapping-up.md
+
+extra-files:
+ - digital-images
diff --git a/pikau/content/pikau-courses/why-digital-technologies/overview.md b/pikau/content/pikau-courses/why-digital-technologies/overview.md
new file mode 100644
index 0000000..d972f32
--- /dev/null
+++ b/pikau/content/pikau-courses/why-digital-technologies/overview.md
@@ -0,0 +1,5 @@
+By the end of this pīkau you should be able to:
+
+- explain the purpose of the new digital technologies content in the technology learning area
+- explain how digital technologies is primarily about people, and not devices
+- identify the two components of digital technologies – Computational Thinking (CT) and Designing Developing Digital Outcomes (DDDO, or Digital Outcomes)
diff --git a/pikau/content/pikau-courses/why-digital-technologies/why-this-matters/already-know-this.md b/pikau/content/pikau-courses/why-digital-technologies/why-this-matters/already-know-this.md
new file mode 100644
index 0000000..6563e9e
--- /dev/null
+++ b/pikau/content/pikau-courses/why-digital-technologies/why-this-matters/already-know-this.md
@@ -0,0 +1,36 @@
+# You might already know some of this
+
+{comment Mahuika: You have already done some relevant teaching}
+
+Digital technologies relates to many ideas that are already taught in schools - but perhaps not the ones that people might think of first!
+
+
+
+
+
+Learning about DT will draw heavily on the capabilities that are expressed in the key competencies of [The New Zealand Curriculum](http://nzcurriculum.tki.org.nz/Key-competencies) (thinking; using language, symbols, and texts; managing self; relating to others; participating and contributing).
+
+For example, when we look at programming in more detail, we’ll see that it involves:
+
+- figuring out what you are going to program (which exercises communication skills to find out what the program should do for others)
+- designing and writing the program (often working with others)
+- testing that it works as needed (which exercises rigour – you want to have the self-discipline to find faults rather than have the users of your program find them)
+- persistence (once a fault has been identified, the cause needs to be tracked down).
+
+Language, symbols, and text are a big part of digital technologies, and students will be exploring new ways to represent and communicate ideas.
+
+Coming up with ideas for digital outcomes involves creativity.
+Perhaps counter-intuitively, creativity thrives when there are constraints on what can be done. Working within the constraints of what can be done digitally provides opportunities for creativity in the rich realm of possibilities to explore.
+
+
+These are all capabilities that you may have already been encouraging in your students.
+
+And while *digital* technologies may seem new, you may already have been doing parts of it while you have been teaching and learning in the technology learning area.
+
+Inquiry learning and problem solving activities are often located in the technology strands – in the “doing and thinking” in [technological practice](http://technology.tki.org.nz/Technology-in-the-NZC/Technological-practice) (brief development, planning, and outcome development and evaluation).
+
+When learners apply specialist disciplinary knowledge and understandings, this falls within the [technological knowledge strand](http://technology.tki.org.nz/Technology-in-the-NZC/Technological-knowledge) – the “knowing” (modelling/testing/trialing, and systems).
+
+The deeper questioning is the “why”, (such as, why does technology change, what drives it and what are the results in made outcomes?) This falls within the [nature of technology strand](http://technology.tki.org.nz/Technology-in-the-NZC/Nature-of-technology) (characteristics of technology and characteristics of technological outcomes).
+
+These strands are woven into the new digital technologies and hangarau matihikocontent through the progress outcomes.
diff --git a/pikau/content/pikau-courses/why-digital-technologies/why-this-matters/how-are-students-better-off.md b/pikau/content/pikau-courses/why-digital-technologies/why-this-matters/how-are-students-better-off.md
new file mode 100644
index 0000000..958bafe
--- /dev/null
+++ b/pikau/content/pikau-courses/why-digital-technologies/why-this-matters/how-are-students-better-off.md
@@ -0,0 +1,29 @@
+# How are your students better off?
+
+{comment Mahuika: How do we look after our students?}
+
+You may have heard people say that young people know all about digital technology.
+But many of them **don’t know what they don’t know**, and often they base their views on stereotypes of the field.
+A devastating consequence of this is that some of the people most needed in the field don’t even know that it might be an exciting option for them.
+Watch these videos from senior tertiary computer science students who nearly missed out on the whole opportunity.
+
+{video url="https://www.youtube.com/embed/zSfzB-Z-mKM"}
+
+{video url="https://www.youtube.com/embed/zSfzB-Z-mKM"}
+
+Another concern is that the subject might only appeal to a particular group of students, and shouldn’t be required for everyone.
+Have a look at these comments from teachers who have been teaching digital technologies for the last few years.
+
+{video url="https://www.youtube.com/embed/zSfzB-Z-mKM"}
+
+There’s also the question of how this relates to careers.
+Having digital technologies in the curriculum is not all about preparing students for careers, but we hope that some will find that this is their passion.
+There are incredible opportunities for employment in this area.
+Employees with strong skills in this area (combining technical and “soft” skills) are in short supply in NZ and overseas, especially in software development.
+
+TechHub NZ has information about the kinds of jobs available:
+
+- [TechHub – IT Careers](https://techhub.nz/IT-Careers)
+- [TechHub – Why IT?](https://techhub.nz/Why-IT)
+
+{video url="https://www.youtube.com/embed/zSfzB-Z-mKM"}
diff --git a/pikau/content/pikau-courses/why-digital-technologies/why-this-matters/is-it-all-about-devices.md b/pikau/content/pikau-courses/why-digital-technologies/why-this-matters/is-it-all-about-devices.md
new file mode 100644
index 0000000..ff827cf
--- /dev/null
+++ b/pikau/content/pikau-courses/why-digital-technologies/why-this-matters/is-it-all-about-devices.md
@@ -0,0 +1,40 @@
+# Is it all about devices?
+
+{comment Mahuika: Let’s focus on people, not things}
+
+{video url="https://www.youtube.com/embed/zSfzB-Z-mKM"}
+
+{video url="https://www.youtube.com/embed/zSfzB-Z-mKM"}
+
+{boxed-text type="pull-out"}
+
+**Activity: Explore a digital view of your own photo**
+
+Try the Pixel viewer demonstrated in the video above by going to the [Computer Science Field Guide – Pixel Value Interactive](http://csfieldguide.org.nz/en/interactives/pixel-viewer/index.html).
+You can drop your own photo onto the page to explore the colours in it.
+
+The RGB colour mixer used in the video is from the [Computer Science field Guide – RGB Colour Mixer](http://www.csfieldguide.org.nz/en/interactives/rgb-mixer/index.html).
+You can use it to see how the three numbers specify the colour.
+
+{boxed-text end}
+
+## Green screening - the hard way!
+
+
+{image file-path="images/pikau/arnold-the-wonder-parrot.jpg" alignment="center" caption="true"}
+
+Arnold the Wonder Parrot
+
+{image end}
+
+This is Arnold the Wonder Parrot, the mascot of the CS Unplugged project.
+You can explore this photo of Arnold at the [following link](http://csfieldguide.org.nz/en/interactives/pixel-viewer/index.html?hide-menu&no-pixel-fill&image=arnold.jpg), but it doesn’t have the colours visible, just their numbers.
+Can you see where the edge of the green is?
+(The G value will be high, and R and B will be low.)
+How about Arnold?
+(Orange pixels will have a high R and G value.)
+What you’re doing manually is green-screening – working out which pixels are the background, and which are the actor in front of the green.
+
+The activity above is looking at green-screen pixels.
+This is a good example of the relationship between CT (computational thinking) and DDDO (designing and developing digital outcomes).
+In DDDO, students use existing software to do green-screening to create new digital outcomes, while in CT, students would consider how to design an algorithm to do the green-screening.
diff --git a/pikau/content/pikau-courses/why-digital-technologies/why-this-matters/users-or-creators.md b/pikau/content/pikau-courses/why-digital-technologies/why-this-matters/users-or-creators.md
new file mode 100644
index 0000000..6f97989
--- /dev/null
+++ b/pikau/content/pikau-courses/why-digital-technologies/why-this-matters/users-or-creators.md
@@ -0,0 +1,10 @@
+# Users or creators?
+
+{comment Māui: We’re turning conventional thinking upside down}
+
+How much do young people actually know about digital technologies?
+Watch these videos for some ideas about this...
+
+{video url="https://www.youtube.com/embed/zSfzB-Z-mKM"}
+
+{video url="https://www.youtube.com/embed/zSfzB-Z-mKM"}
diff --git a/pikau/content/pikau-courses/why-digital-technologies/wrapping-up.md b/pikau/content/pikau-courses/why-digital-technologies/wrapping-up.md
new file mode 100644
index 0000000..df9b127
--- /dev/null
+++ b/pikau/content/pikau-courses/why-digital-technologies/wrapping-up.md
@@ -0,0 +1,5 @@
+# Wrapping up
+
+This Pīkau/toolkit has given a short introduction to the idea of computational thinking.
+We’ll go into more detail in a second Pīkau/toolkit that explores a more international view of the concept.
+A lot of this will become clearer as you engage with further Pīkau/toolkits about teaching computational thinking.
diff --git a/pikau/content/topics.yaml b/pikau/content/topics.yaml
index df5a126..c6bdab8 100644
--- a/pikau/content/topics.yaml
+++ b/pikau/content/topics.yaml
@@ -2,3 +2,4 @@ dddo: Designing and Developing Digital Outcomes
ct: Computational Thinking
dl: Digital Leaders
housekeeping: Housekeeping
+general: General
diff --git a/pikau/management/commands/_PikauCourseLoader.py b/pikau/management/commands/_PikauCourseLoader.py
index 5d1bb2b..6128972 100644
--- a/pikau/management/commands/_PikauCourseLoader.py
+++ b/pikau/management/commands/_PikauCourseLoader.py
@@ -103,7 +103,6 @@ def load(self):
heading_required=True,
remove_title=True,
)
- print(unit_content.required_files["images"])
# Check files in content
for filename in unit_content.required_files["images"]:
pikau_course.files.add(find_file(filename=filename))
diff --git a/static/images/pikau/arnold-the-wonder-parrot.jpg b/static/images/pikau/arnold-the-wonder-parrot.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..2dbe6f9f3031c7e22443b5fd29022270cb5c4113
GIT binary patch
literal 306527
zcmbTdXH-*9_%)i)o7A9y^qPPuB_O@GB-Bu(sdNYeQlv`<1*A72QbGwG6bMa3id3bU
z0Me!RqEsp3<@bN@x_7Pn>Avrrb#U
zJuz`86v`zet0*I(a9)5#XwDgS3thd=Y=%V5h
zY-w3}MP+>huCb}PrS)U?m!96f{(-@-c*6L^NWi{SJ%z#{*Tko`Zv{$E@(02*T8&EOF;0F(h6
z;foH$$Jn!zJ+;ddY(Gos%gti)q<;W-0B8)Nt)8x92sKyes+s%-roEqjb1-h`B9c#7);UEo=AohzmRbqpqGXCIq92G=quH7$-vR?yYTUS#}
zr{73>^(sBO=hdru9e}YhV7LEWocyJoB;k^PFqEh0aXt?=x`|3p;Q@!2jtv;QrEN(P
zy#+&zAq~a7^1XCDA>)boYzC&2ioNie5ZAgYvkl6>5RxWA&}$IWC@4DVn8C&)(@b}x
zU4O4vV=iILl9wpID8Vil%z_-#2KhoM)Q83514|1m)tOjr%{phoO*NHes$Q3Z1=Z!)
zAO_Y1JsuvG^>=U=Oo@QJA_Qklq&ljf5#qv9s*p<$q3V`gB*5nNR?%pgLvm2xF$3SA
zU?~6?p(U=moJzzQJ>kbJD??V*=HQfL#Or}-SyFC2_$$}+8=-|Fm<&3PFAS8M7vCy%3B&Y`GY^UOI+k(;`)q8y|92FqF{f)gjf2#BzXn
zk~qY*z@Q~nUSJg36PmH45-oFFN~kD}C@e*zP`5})T`A&lk;`f%D2AurJ`opYmXW&v
z#bPQ&mK!>Jr=4B
zqZPhICYUw3r3%!Dx6Tjf8b&yUPQTojFrjawTy;(e5!RdRdzzv7Ev-Y?UOCh3DJhi?M{@N4ZWaZ|c>
zE56W-*O%$O7s=O+(rVms>R*XHi_^{SXU~7sE#7dP`7-CJtZU4`q8YRO_b;hsq-I@g
zK1V?-hhi@&|Lv5T=A3&4JA7&Z8yp=`dmw
z71tq5NYam*$NvFhG;-Pn{H*ZPMGbB3+SKf*I+Gyu*Eab^a4qGa%lFaN{(k_=CMl9j
z!Gh;@HMqa$;^XZ0=r66Q<|0QChvl4+8Solx%B2|TRf3jUF7bXp*JNHfo$$UJaZBi4
z7;xAMS1)TJp5{QKT~3{PF(KbdEwA7l452Xh88*tpNp?(B^#8mzr8je$!K7~rf1TAm
z!10`&UW{XKG(|#W>Ydd19O-)>*gVpJvLACkI`0Fo!z>4AO~3q39X9_ICgB(d^EJp|
z-|*T;HD&z+pjsF<5*%B1<;H|6n!Tu|pUf?AK7RYco**n+&5K~{SN2)Yud{QUur95AE=<+rxt##iuzV`w|4Ih<@&O2Jx+iy$Gr>7@>n-xC=J~{CZ4Tv
z+VYE1A&7D=dHISR!I{of6`X&SU*pX#4lkagWtQe%H+Ssd%nZzeKtK51`sQK<{Xb+z
zmFRH1tA+pFUOSL{4)PIRD$^CZ6qdX8Z77!fTK^c4`;9VLwhtjLdSNDwIq>(+o~_d+
z4FZ}ZxTctE`Iki7co0K(rb1D*5@cJ`%-W%=gj;?58VPn%e4N)O&rFXL#v@Gj1>U*r
zBfL!P5;CH1Kj2-Ly8DjrJ?6?)APMFmirc7=a^2P`)C^}FDSMFguA^3%PEH$$peI+6
zGi0oDowhek51doWzn#Zac8|~0g!M!SpW~{EQr%e-Tls}erSaqzI=JdTr=po=;@BSw
zN=NG=lY`V%a|(-6|CX_GWX4_C)t2)v%fIMEPLEdb0XC*gr8OQ!7vdVeRQ(I0}*>41u
zY|Q@wcpgjjtsd@;?E%&r@Pz|=#qh7Y*f3Ucb#`-NKM?1;H=K`ZGxVJFi*(;Wm!We*iY!&rP={rNm+PIs$T;NBr^w
zK+U74!7fEl1Tvc{{{dcvT~sc{gH0(%-?EO({arDCYrDVioZ&p2W&p9m=$`a1p&47?
zTjoiU0)53OkJp}WJgn*zVYPX?(ai`aox{lIAwPR&8%*7*Cl{PD1SgELgk{~#GPv5B
z(vdAlL9g)a%i<5$rV?+}ElqZ7yHR&lOdW#&2M~(T!cApt^`A4L&dSUtSRxrYil6$HE`J+;(yjI+9ZG)=5fr|NHY1
zvl)d$izlUwR1r5Y31-R_IQrbRAyx21_%7h+>)ZJx~ofkptpF1FP!$T3Os
zYWqj52mY4y!pyy>mTHv~h8qrpL`^kv&^oEz5x*}cS72$!<8R6V>s1m76p%?|ZS9B8
zei$pIBIuHNMXLl~UK*-JIo!_Ta!EsEX#
zPB20PF{H&TQ0K{nF(6C}C8jLkG-GR+yM`opEg#!^$f4=vTK7iYp
z9VETRXQAmrWwCqKy|kR;E#y0}J^d%G7>d@wv?{c9`7fVIP@BI1A
zyCA$xIzr#jM<;b4n{!;YpQTq`=3oY6uM4BlM@gzG#|V&8c;!c?5Moyr-l_Bu=bB`f
zCJ^Tbf_@X)dB`B*aM>N03dI-vyM+Q>MHd!ae;M(p^|(g>#-6S$r~z>9S{rJkXZ02=+H>*DcjIrMoN`e4O_^?|$U9`4+A9sVV~nN@PAq}qUZuRsN0sKHq7zOqg(x{=gpUqPFr3}0@gWJ?
zTf3u1pTPuAJ>_N;F}Q