from api.test_utils import DefaultUserTestCase
from core.tests.base_test import SkillboxTestCase
from portfolio.factories import ProjectEntryFactory
from portfolio.migration_helpers import migrate_project_entries
from portfolio.models import ProjectEntry

ACTIVITY='Kill Thanos'
REFLECTION='He sucks'
NEXT_STEPS='Go for the head'

class ProjectEntryMigrationTestCase(SkillboxTestCase):
    def setUp(self):
        self.createDefault()
        self.project_entry = ProjectEntryFactory(
            activity=ACTIVITY,
            reflection=REFLECTION,
            next_steps=NEXT_STEPS
        )

    def test_migration(self):
        self.assertEqual(self.project_entry.description, '')
        self.assertEqual(self.project_entry.activity, ACTIVITY)
        self.assertEqual(self.project_entry.reflection, REFLECTION)
        self.assertEqual(self.project_entry.next_steps, NEXT_STEPS)

        migrate_project_entries(ProjectEntry)

        project_entry = ProjectEntry.objects.get(id=self.project_entry.id)
        self.assertEqual(project_entry.activity, ACTIVITY)
        self.assertEqual(project_entry.reflection, REFLECTION)
        self.assertEqual(project_entry.next_steps, NEXT_STEPS)
        self.assertEqual(
            project_entry.description,
            f'Tätigkeit:\n{ACTIVITY}\n\n\nReflexion:\n{REFLECTION}\n\n\nNächste Schritte:\n{NEXT_STEPS}'
        )
