Ejemplo n.º 1
0
    def test_creating_and_retrieving_projects(self):
        first_project = Project()
        first_project.title = '1st project'
        first_project.description = '1st desc'
        first_project.save()

        second_project = Project()
        second_project.title = '2nd project'
        second_project.description = '2nd desc'
        second_project.save()

        projects = Project.objects.all()
        self.assertEqual(projects.count(), 2)

        first_saved_project = projects[0]
        self.assertEqual(first_saved_project.title, '1st project')
        self.assertEqual(first_saved_project.description, '1st desc')

        second_saved_project = projects[1]
        self.assertEqual(second_saved_project.title, '2nd project')
        self.assertEqual(second_saved_project.description, '2nd desc')
Ejemplo n.º 2
0
    def run_from_argv(self, *args):

        languages = (
            'PHP',
            'MySQL',
            '(X)HTML',
            'CSS',
            'Python/Django',
            'JavaScript/jQuery',
        )

        # Build Technologies
        print "Adding languages..."
        for lang in languages:
            l = Language()
            l.name = lang
            l.save()

        today = datetime.date.today()
        start = today - datetime.timedelta(weeks=15)

        print "Adding projects..."
        for i in range(4):
            if i == 0:
                i = 1

            languages = Language.objects.get(pk=i)

            p = Project()
            p.begun = start
            p.completed = today
            p.title = "Project Number %s" % (i,)
            p.slug = "project-%s" % (i,)
            p.client = "Myself"
            p.description = "I did stuff on this project"
            p.save()
            p.languages.add(languages)
            p.save()