Example #1
0
 def test_delete_university(self):
     u = University(name='VU', description='Test', username="******", password="******", location="Amsterdam")
     db.session.add(u)
     db.session.commit()
     University.delete_university(u.id)
     u = University.query.get(u.id)
     self.assertIsNone(u)
Example #2
0
 def test_match_mentor_university(self):
     ''' 
     tests match_with_mentor() with 1 student and 2 mentors, 
     one of whom shares a university with student. 
     Expected output: s should match with m2
     '''
     s = User()
     s.user_role = 'student'
     s.name = 'studentName'
     db.session.add(s)
     m1 = User()
     m1.user_role = 'mentor'
     m1.name = 'mentor1'
     db.session.add(m1)
     m2 = User()
     m2.user_role = 'mentor'
     m2.name = 'mentor2'
     db.session.add(m2)
     u = University()
     u.name = 'Temple'
     u.users.append(s)
     u.users.append(m2)
     db.session.add(u)
     db.session.commit()
     s.match_with_mentor()
     self.assertTrue(s.mentor.name == m2.name)
Example #3
0
 def test_match_mentor_university(self):
     ''' 
     tests match_with_mentor() with 1 student and 2 mentors, 
     one of whom shares a university with student. 
     Expected output: s should match with m2
     '''
     s = User()
     s.user_role = 'student'
     s.name = 'studentName'
     db.session.add(s)
     m1 = User()
     m1.user_role = 'mentor'
     m1.name = 'mentor1'
     db.session.add(m1)
     m2 = User()
     m2.user_role = 'mentor'
     m2.name = 'mentor2'
     db.session.add(m2)
     u = University()
     u.name = 'Temple'
     u.users.append(s)
     u.users.append(m2)
     db.session.add(u)
     db.session.commit()
     s.match_with_mentor()
     self.assertTrue(s.mentor.name == m2.name)
Example #4
0
 def test_match_mentor_fewestStudents(self):
     ''' 
     tests match_with_mentor() with 1 student and 2 mentors, 
     who all share a university, but mentor2 has fewer
     students than mentor1. 
     Expected output: s should match with m2
     '''
     s = User()
     s.user_role = 'student'
     s.name = 'studentName'
     m3 = User()
     m3.user_role = 'mentor'
     m3.name = 'mentor3'
     m4 = User()
     m4.user_role = 'mentor'
     m4.name = 'mentor4'
     u = University(name='Temple')
     u.users.append(s)
     u.users.append(m3)
     u.users.append(m4)
     m3.students.append(User())
     s.match_with_mentor()
     self.assertTrue(s.mentor.name == m4.name)
Example #5
0
def create_university(request):
    university = University(name=request.POST['name'],
                            address=request.POST['address'],
                            subjects=request.POST['subjects'])
    university.save()
    return redirect('/app/universities/')
Example #6
0
    def parse(self, **kwargs):
        worksheet = GoogleSheetsParser.get_worksheet(self, '15Q8sDyG_eBUHMcriIAHTmwDcdSdJSSLNAo34iBZKyJk')

        i = 2
        while True:
            values_list = worksheet.row_values(i)
            i += 1

            if not values_list[0]:
                break

            if values_list[5] == kwargs['options']['wave']:
                try:
                    university = University.objects.get(
                        name=values_list[0]
                    )
                except ObjectDoesNotExist:
                    try:
                        city = City.objects.get(
                            name=values_list[3]
                        )
                    except ObjectDoesNotExist:
                        try:
                            region = Region.objects.get(
                                name='unknown'
                            )
                        except ObjectDoesNotExist:
                            try:
                                country = Country.objects.get(
                                    name=values_list[2]
                                )
                            except ObjectDoesNotExist:
                                country = Country(
                                    name=values_list[2]
                                )
                                country.save()
                            region = Region(
                                name='unknown',
                                country=country,
                            )
                            self.unknown_region = True
                            region.save()
                        city = City(
                            name=values_list[3],
                            region=region,
                            lat=0,
                            lon=0
                        )
                        self.city_count += 1
                        city.save()

                    university = University(
                        name=values_list[0],
                        abbr=values_list[1],
                        city=city,
                        site=values_list[4]
                    )
                    self.university_count += 1
                    university.save()

        result = [
            'Wave ' + str(kwargs['options']['wave']),
            'New University: ' + str(self.university_count),
        ]
        if self.city_count > 0:
            result.append('------')
            result.append('Check this situation! It is not normal!')
            result.append('------')
            result.append('New City: ' + str(self.city_count))
            if self.unknown_region:
                result.append('Added Region "unknown"')

        return result
def test_can_create_uni(db: Session) -> None:
    uni = University(name_translations={"en": "Test Uni", "he": "אוני בדיקה"})

    terms = [
        Term(id=1, name_translations={"en": "Semester 1"}),
        Term(id=2, name_translations={"en": "Semester 2"}),
        Term(id=3, name_translations={"en": "Semester 1/2"}),
    ]

    fac = Faculty(
        university=uni,
        id="facCSE",
        name_translations={
            "en": "Computer Science and Engineering",
            "he": 'ביה"ס להנדסה ולמדעי המחשב',
        },
    )
    dep = Department(
        faculty=fac,
        id="521",
        name_translations={"en": "Computer Science", "he": "מדעי המחשב"},
    )
    dep2 = Department(
        faculty=fac,
        id="583",
        name_translations={
            "en": "Electrical & Computer Engineering",
            "he": "הנדסת חשמל ומחשבים",
        },
    )
    tracks = [
        Track(
            university=uni,
            id="23010",
            degree=DegreeType.Bachelors,
            name_translations={"he": 'מדמ"ח חד חוגי מורחב'},
            departments=[dep],
        ),
        Track(
            university=uni,
            id="125860",
            degree=DegreeType.Bachelors,
            name_translations={"he": "הנדסת חשמל ומחשבים עם התחמות בהנדסת מחשבים"},
            departments=[dep2],
        ),
    ]

    course_names = [
        "Infi1", "Infi2", "LinAlg1", "LinAlg2", "Probability", "IML", "Logic1", "LogicCS", "Intro2CS"
    ]

    courses = {
        name: Course(
            university=uni,
            id=f"C_{name.upper()}",
            name_translations={
                "en": name
            },
            term=terms[0],
            course_credits=1337
        ) for name in course_names
    }

    db.add_all(courses.values())

    infi1 = singleton_course_node(courses["Infi1"])
    infi2 = singleton_course_node(courses["Infi2"])
    infi1.children.append(infi2)

    lin1 = singleton_course_node(courses["LinAlg1"])
    lin2 = singleton_course_node(courses["LinAlg2"])
    lin1.children.append(lin2)

    prob = singleton_course_node(courses["Probability"])
    prob.parents.append(lin2)

    iml = singleton_course_node(courses["IML"])
    logic1 = singleton_course_node(courses["Logic1"])
    logic_cs = singleton_course_node(courses["LogicCS"])
    intro = singleton_course_node(courses["Intro2CS"])

    logic_cs.parents.append(intro)
    iml.parents.extend([prob, infi2, lin2])

    or_node = ORNode()
    or_node.university = uni
    or_node.children.extend([logic1, logic_cs])

    cs_extended_root = DAGRootNode()
    cs_extended_root.track = tracks[0]
    cs_extended_root.university = uni
    cs_extended_root.children.extend([
        infi1, lin1, or_node, intro
    ])

    db.add(cs_extended_root)

    db.commit()
Example #8
0
def populate():
  db.drop_all()
  db.create_all()

  #create university
  temple = University(name="Temple University", description="asdfasdfasdfasdf")

  #create general tasks for temple
  gt_1 = GeneralTask(title="FAFSA", description="Max loves Hackuna Matata", deadline=datetime.datetime(2014,5,5), university=temple)
  gt_2 = GeneralTask(title="Housing Application", description="I love comic sans", deadline=datetime.datetime(2014,6,6), university=temple)
  gt_3 = GeneralTask(title="Scholarship Application", description="Ali is the best!!!!", deadline=datetime.datetime(2014,12,5), university=temple)
  gt_4 = GeneralTask(title="Speak to Advisor", description="WOOOOOOOOOO!!!!!", deadline=datetime.datetime(2014,12,7), university=temple)

  #create mentor
  annie = User(name="Annie Meng", email="*****@*****.**", phone='1234567890', password="******", user_role="mentor", university=temple, bio="Lorem ipsum dolor sit amet praesent. Libero vehicula turpis. Neque fermentum augue rutrum accumsan eget pretium sapien eu. Sed sed similique sed turpis suscipit rhoncus justo sapien faucibus commodo nibh. Velit aliquet pellentesque turpis eget in. Arcu eu nec. Nulla sollicitudin quis. In placerat eleifend vestibulum animi nullam amet ipsum lorem et a habitant. Feugiat pellentesque inceptos. Nulla vel cursus. Pulvinar pede augue amet nibh tempus. Leo at sollicitudin. Sit amet quo. Viverra integer nullam felis bibendum lectus. Nulla accumsan ut curabitur velit sollicitudin nam nisl felis. Aliquam aenean exercitation diam facilisis mauris. Nulla sit sollicitudin morbi sit commodo arcu.")

  #create students
  max_mc = User(name="Max McCarthy", email="*****@*****.**", password="******", phone='2678809546', user_role="student",university=temple)
  max_mc.mentor = annie

  maya = User(name="Maya Ebsworth", email="*****@*****.**", password="******", phone='3234567890', user_role="student", university=temple)
  maya.mentor = annie

  ayush = User(name="Ayush Goyal", email="*****@*****.**", password="******", phone='4234567890', user_role="student", university=temple)
  ayush.mentor = annie

  ali = User(name="Ali Altaf", email="*****@*****.**", password="******", user_role="admin")

  #assign tasks to students
  max_1 = Task(title="FAFSA", description="Max loves Hackuna Matata", deadline=datetime.datetime(2014,5,5), student=max_mc, completed=True)
  max_2 = Task(title="Housing Application", description="I love comic sans", deadline=datetime.datetime(2014,6,6), student=max_mc, completed=True)
  max_3 = Task(title="Scholarship Application", description="Ali is the best!!!!", deadline=datetime.datetime(2014,12,5), student=max_mc)
  max_4 = Task(title="Speak to Advisor", description="WOOOOOOOOOO!!!!!", deadline=datetime.datetime(2014,12,7), student=max_mc)

  maya_1 = Task(title="FAFSA", description="maya loves Hackuna Matata", deadline=datetime.datetime(2014,5,5), student=maya)
  maya_2 = Task(title="Housing Application", description="I love comic sans", deadline=datetime.datetime(2014,6,6), student=maya)
  maya_3 = Task(title="Scholarship Application", description="Ali is the best!!!!", deadline=datetime.datetime(2014,12,5), student=maya)
  maya_4 = Task(title="Speak to Advisor", description="WOOOOOOOOOO!!!!!", deadline=datetime.datetime(2014,12,7), student=maya)

  ayush_1 = Task(title="FAFSA", description="ayush loves Hackuna Matata", deadline=datetime.datetime(2014,5,5), student=ayush)
  ayush_2 = Task(title="Housing Application", description="I love comic sans", deadline=datetime.datetime(2014,6,6), student=ayush, completed=True)
  ayush_3 = Task(title="Scholarship Application", description="Ali is the best!!!!", deadline=datetime.datetime(2014,12,5), student=ayush)
  ayush_4 = Task(title="Speak to Advisor", description="WOOOOOOOOOO!!!!!", deadline=datetime.datetime(2014,12,7), student=ayush)

  faq_1 = FAQ(question="Hello?", answer="Hello.")
  faq_2 = FAQ(question="Sup?", answer="Sup.")
  faq_3 = FAQ(question="???", answer="...")

  db.session.add(temple)

  db.session.add(annie)

  db.session.add(max_mc)
  db.session.add(maya)
  db.session.add(ayush)
  db.session.add(ali)

  db.session.add(gt_1)
  db.session.add(gt_2)
  db.session.add(gt_3)
  db.session.add(gt_4)

  db.session.add(max_1)
  db.session.add(max_2)
  db.session.add(max_3)
  db.session.add(max_4)

  db.session.add(maya_1)
  db.session.add(maya_2)
  db.session.add(maya_3)
  db.session.add(maya_4)

  db.session.add(ayush_1)
  db.session.add(ayush_2)
  db.session.add(ayush_3)
  db.session.add(ayush_4)

  db.session.add(faq_1)
  db.session.add(faq_2)
  db.session.add(faq_3)