示例#1
0
 def question_tag_test_data(self, question_test_data):
     test_tag = Tag()
     test_tag.tag_name = "test_tag_2"
     test_tag.save()
     new_pair = Question_Tag()
     new_pair.question = question_test_data
     new_pair.tag = test_tag
     new_pair.save()
     return test_tag
示例#2
0
    def generate_data(apps, schema_editor):
        from home.models import Tag, Question_Tag, Question
        tag_test_data = [('Pitagoras'), ('5th_Grade'), ('Bagrut_Exam'),
                         ('Hebrew')]
        question_tag_test_data = [
            ('Question from  Benny Goren Book', 'Pitagoras'),
            ('Question from  Benny Goren Book', 'Bagrut_Exam'),
            ('question about ants', '5th_Grade'), ('Need help', 'Hebrew')
        ]

        with transaction.atomic():
            # Create Tag objects
            for tag_name in tag_test_data:
                Tag(tag_name=tag_name).save()
            # Create Question_Tag objects
            for title, tag_name in question_tag_test_data:
                curr_tag = Tag.objects.filter(tag_name=tag_name)
                curr_question = Question.objects.filter(title=title)
                Question_Tag(question=curr_question[0], tag=curr_tag[0]).save()
示例#3
0
    def createTag(self, skill_id, skill_name, description):
        tag = Tag(skill_id=skill_id,
                  skill_name=skill_name,
                  description=description)
        serverResult = ServerResult()
        #Special checks before creating tags
        if (len(skill_name) < 3):
            serverResult.error.append("Skill name")
            return serverResult

        try:
            tag.full_clean()
            tag.save()
            serverResult.model = tag
        except ValidationError as v:
            serverResult.error.append(v)
        except IntegrityError as i:
            serverResult.error.append(i)
        return serverResult
    def generate_data(apps, schema_editor):

        tag_test_data = [
            'benny_goren',
            'need_help',
            'algebra',
            'java',
            'god',
            'python',
            'c#',
            'geometry',
            'all_my_sons',
            'israel',
            'the_holocaust',
            'urgent',
            'trigonometry',
            'Bagrut',
            '1948_book',
            'novel'

        ]
        question_tag_test_data = [
            ('8', 'algebra'),
            ('1', 'Bagrut'),
            ('3', 'urgent'),
            ('5', 'urgent'),
            ('6', 'all_my_sons'),
            ('6', 'urgent'),
            ('6', 'israel'),
            ('7', 'novel'),
            ('9', '1948_book'),
            ('10', 'c#'),
            ('10', 'the_holocaust'),
            ('11', 'geometry'),
            ('11', 'urgent'),
            ('11', 'benny_goren'),
            ('13', 'all_my_sons'),
            ('14', 'java'),
            ('14', 'all_my_sons'),
            ('15', 'israel'),
            ('16', 'israel'),
            ('20', 'benny_goren'),
            ('20', 'all_my_sons'),
            ('22', 'need_help'),
            ('22', 'java'),
            ('22', 'algebra'),
            ('25', 'algebra'),
            ('25', 'geometry'),
            ('26', 'python'),
            ('28', 'python'),
            ('28', 'trigonometry'),
            ('29', 'the_holocaust'),
            ('29', 'algebra'),
            ('29', 'israel'),
            ('31', 'the_holocaust'),
            ('31', 'java'),
            ('31', 'c#'),
            ('32', 'israel'),
            ('33', 'Bagrut'),
            ('33', 'algebra'),
            ('34', 'c#'),
            ('36', 'god'),
            ('38', 'israel'),
            ('38', 'c#'),
            ('40', 'trigonometry'),
            ('40', 'python'),
            ('40', 'israel'),
            ('41', 'java'),
            ('42', 'java'),
            ('42', 'god'),
            ('43', 'java'),
            ('43', 'algebra'),
            ('44', 'c#'),
            ('44', 'java'),
            ('45', 'trigonometry'),
            ('45', 'python'),
            ('48', 'urgent'),
            ('48', 'Bagrut'),
            ('48', 'java'),
            ('49', 'god'),
            ('49', 'c#'),
            ('49', 'python'),
            ('51', 'java'),
            ('54', 'the_holocaust'),
            ('58', 'god'),
            ('59', 'python'),

        ]

        with transaction.atomic():
            # Create Tag objects
            for tag_name in tag_test_data:
                Tag(tag_name=tag_name).save()
            # Create Question_Tag objects
            for id, tag_name in question_tag_test_data:
                curr_tag = Tag.objects.get(tag_name=tag_name)
                curr_question = Question.objects.get(id=id)
                Question_Tag(question=curr_question, tag=curr_tag).save()
 def tag_test_data(self):
     tag = Tag(tag_name='test_tag_1')
     tag.save()
     return tag
 def test_tags_feed_no_result(self):
     assert Tag.tags_feed('testtesttesttest').count() == 0
 def test_tags_feed_after_delete(self, tag_test_data):
     Tag.objects.filter(tag_name='test_tag_1').delete()
     assert Tag.tags_feed().count() == 20
 def test_tags_feed_with_filter(self, tag_test_data):
     assert Tag.tags_feed('_t').count() == 1
 def test_tags_feed_no_parameters(self):
     assert Tag.tags_feed().count() == 20
 def test_check_tag_array_invalid_data(self, invalid_tags):
     assert Tag.check_tag_array(invalid_tags) is False
 def test_check_tag_array_valid_data(self, valid_tags):
     assert Tag.check_tag_array(valid_tags) is True
示例#12
0
    def generate_data(apps, schema_editor):
        from home.models import Tag, Question_Tag, Question

        tag_test_data = [
            "Pitagoras",
            "5th_Grade",
            "Bagrut_Exam",
            "Hebrew",
            "benny_goren",
            "need_help",
            "algebra",
            "java",
            "god",
            "python",
            "csharp",
            "geometry",
            "all_my_sons",
            "israel",
            "the_holocaust",
            "urgent",
            "trigonometry",
            "Bagrut",
            "1984_book",
            "novel",
        ]

        question_tag_test_data = [
            ("8", "Pitagoras"),
            ("8", "5th_Grade"),
            ("2", "5th_Grade"),
            ("2", "Pitagoras"),
            ("2", "Bagrut_Exam"),
            ("14", "Hebrew"),
            ("14", "Bagrut_Exam"),
            ("8", "algebra"),
            ("1", "Bagrut"),
            ("3", "urgent"),
            ("5", "urgent"),
            ("6", "all_my_sons"),
            ("6", "urgent"),
            ("6", "israel"),
            ("7", "novel"),
            ("9", "1984_book"),
            ("10", "csharp"),
            ("10", "the_holocaust"),
            ("11", "geometry"),
            ("11", "urgent"),
            ("11", "benny_goren"),
            ("13", "all_my_sons"),
            ("14", "java"),
            ("14", "all_my_sons"),
            ("15", "israel"),
            ("16", "israel"),
            ("20", "benny_goren"),
            ("20", "all_my_sons"),
            ("22", "need_help"),
            ("22", "java"),
            ("22", "algebra"),
            ("25", "algebra"),
            ("25", "geometry"),
            ("26", "python"),
            ("28", "python"),
            ("28", "trigonometry"),
            ("29", "the_holocaust"),
            ("29", "algebra"),
            ("29", "israel"),
            ("31", "the_holocaust"),
            ("31", "java"),
            ("31", "csharp"),
            ("32", "israel"),
            ("33", "Bagrut"),
            ("33", "algebra"),
            ("34", "csharp"),
            ("36", "god"),
            ("38", "israel"),
            ("38", "csharp"),
            ("40", "trigonometry"),
            ("40", "python"),
            ("40", "israel"),
            ("41", "java"),
            ("42", "java"),
            ("42", "god"),
            ("43", "java"),
            ("43", "algebra"),
            ("44", "csharp"),
            ("44", "java"),
            ("45", "trigonometry"),
            ("45", "python"),
            ("48", "urgent"),
            ("48", "Bagrut"),
            ("48", "java"),
            ("49", "god"),
            ("49", "csharp"),
            ("49", "python"),
            ("51", "java"),
            ("54", "the_holocaust"),
            ("58", "god"),
            ("59", "python"),
        ]

        with transaction.atomic():
            # Create Tag objects
            for tag_name in tag_test_data:
                Tag(tag_name=tag_name).save()
            # Create Question_Tag objects
            for question_id, tag_name in question_tag_test_data:
                curr_tag = Tag.objects.filter(tag_name=tag_name)
                curr_question = Question.objects.filter(id=question_id)
                Question_Tag(question=curr_question[0], tag=curr_tag[0]).save()