Exemple #1
0
 def setUp(self):
     ce = models.CultureEvent(title='Example CE1',
                              description_plain_text='A first CE')
     ce.save()
     self.text1 = models.Text(text_title='Text 1',
                              last_modified_by='Tester',
                              phonetic_standard='1',
                              discourse_type='1',
                              orthographic_text='Ortho1',
                              ce=ce)
     self.text1.save()
     self.text2 = models.Text(text_title='Text 2',
                              last_modified_by='Tester',
                              phonetic_standard='2',
                              discourse_type='2',
                              orthographic_text='Ortho2',
                              ce=ce)
     self.text2.save()
Exemple #2
0
 def setUp(self):
     ce = models.CultureEvent(
         title='Example CE1',
         description_plain_text='A culture event happened',
         differences='Last time it was different')
     ce.save()
     text = models.Text(ce=models.CultureEvent.objects.get(pk=3),
                        audio='musicFile.ogg',
                        phonetic_text='foᵘnɛtɪks',
                        orthographic_text='orthographic')
     text.save()
Exemple #3
0
def insert_example_CEs(apps, schema_editor):
    example_ce_1 = models.CultureEvent(
        title="Example CE",
        last_modified_by='CLAHubDev',
        description_plain_text=
        '''We arranged with a family beforehand that we'd come with the and see how laundry is done.
The family was waiting for us when we arrived, they had remembered we were coming.
The children were sent by some ladies to get some buckets and 2 girls went to get water from the public well.
We went to an area that had a big piece of hard plastic that lying on a big tractor tire. 
One girl first made all the clothes wet in one bucket and transferred them to another bucket. Another girl put soap in this bucket and made the water soapy. Then she took out the clothes one by one, laid them on the plastic and brushed them with a brush. Clothes with stains were treated with bleach and put aside to soak for a couple of minutes. Fragile clothes were kneaded together with soap and not brushed. 
In between someone had gotten 2 more buckets of water.
One was to rinse off the soap. Then the second one to rinse again.
The wet clothes were put in another bucket again and hung up at the washing line.''',
        interpretation=
        '''There were no men present at all suggesting that laundry is women's work.''',
        differences='I\'ve seen people washing at a nearby stream too')
    example_ce_1.save()
    with open(os.path.join(example_data_folder, 'example_audio1.mp3'),
              'rb') as file:
        file = file.read()
        audio = SimpleUploadedFile(name='example_audio1.mp3',
                                   content=file,
                                   content_type='audio')

        example_text_1 = models.Text(
            ce=example_ce_1,
            text_title='Maryanne talking about doing laundry',
            phonetic_text=
            '''oke fəst mipla ɡo pulapim wara kam kapsaⁱtim insaⁱt lo bakɛt sɛrim wara biloŋ 
            raᵘsim dəti lo rins na mipla fəst mipla wasim dəti bihaⁱn mipla putim ɡo lo sop wara mipla 
            brasim ol klots pinis sampla blo blits ja mipla blitsim ol pinis mipla putim go lo rins wara 
            mipla rinsim rinsim sop raᵘsim mipla ɡo lo klin wara mipla rinsim naᵘ mipla ɡo haŋgamapim lo 
            laⁱn ɛm tʃol''',
            phonetic_standard='1',
            discourse_type='3',
            last_modified_by='CLAHubDev',
            orthographic_text='''Orthographic text goes here :)''',
            audio=audio)
        example_text_1.save()
        example_ce_1.tags.add('Example')

    for i in range(1, 5):
        with open(
                os.path.join(example_data_folder,
                             'example_CE_pic%s.jpg' % str(i)), 'rb') as file:
            file = file.read()
            picture = SimpleUploadedFile(name='example_CE_pic%s.jpg' % str(i),
                                         content=file,
                                         content_type='image')
            example_pic = models.Picture(picture=picture, ce=example_ce_1)
            example_pic.save()

    visit = models.Visit(ce=example_ce_1,
                         team_present='Gerdine, Becky',
                         nationals_present='Maryanne and family',
                         date='2016-02-06')
    visit.save()
    question1 = models.Question(
        ce=example_ce_1,
        asked_by='CLAHubDev',
        last_modified_by='CLAHubDev',
        question=
        'Do some families struggle to afford soap, or does everyone have it?')
    question1.save()
    question2 = models.Question(
        ce=example_ce_1,
        asked_by='CLAHubDev',
        last_modified_by='CLAHubDev',
        question='How dirty do people let their clothes get before washing?',
        answer=
        'Pretty dirty :), but they do take more care to not get them so dirty in the first place compared to us.'
    )
    question2.save()

    example_ce_2 = models.CultureEvent(
        title='Explanation of CLAHub features',
        last_modified_by='CLAHubDev',
        description_plain_text=
        '''This area is for describing the Culture Event (CE) in general. The
         description field should contain objective information (no interpretation, guesses,
          musings or language learner POV) about the CE.Your
        team should work together to build a complete page for each CE. The intention of CLAHub is that
        pages become a snapshot of the team's best information on any given CE. That means there will
        be a single \'Harvesting Sago\' CE that team members add information to over time. There
        shouldn\'t be \'Team member A goes fishing\' and \'Team member B goes fishing\' CEs, but
        rather if team member A creates a Fishing CE, team member B should build on it.
         
         Language learning will require that both team member A and team member B both have personalised
         notes elsewhere. For instance team member A might be working on learning basic vocabulary,
          but Team member B is further along and is working on learning something else. CLAHub isn\'t 
          designed to file those notes and they should be kept separately by each language learner so
          they can learn as productively as possible
          
          The description field is unique in CLAHub in that it will automatically create cross
          references between CEs by simply reading the text. All you need to do to create a link
          to anther CE is to type it's title. example ce for example.''',
        interpretation=
        '''Typically a CE has much more going on than what can be documented on
        a surface level. This field is a place where you can write up implicit information about a 
        CE. As a language learner you're likely to guess wrong at times and interpret CEs incorrectly,
        this is why the deescription is to remain objective. This field allows the team to dig deeper,
        while keeping objective facts separate from the team's understanding of a culture's worldview''',
        differences=
        'Multiple team members will be contributing to each CE and team members will'
        'participate in CEs multiple times. The description field allows the team to write'
        'a generalized description of the CE, while the variations field allows team members'
        'to include information about times the CE deviated from the regular pattern, or to'
        'add specific information from their participation')
    example_ce_2.save()
Exemple #4
0
 def test_string_method(self):
     ce = models.CultureEvent(title='Example CE1')
     text = models.Text(ce=ce,
                        phonetic_text='djaŋɡo',
                        text_title='example text')
     self.assertEqual(str(text), 'example text')
    def setUp(self):
        # the prexisiting model objects variable is used to exclude example data
        self.prexisiting_model_objects = {
            'CE': len(models.CultureEvent.objects.all()),
            'Text': len(models.Text.objects.all()),
            'Visit': len(models.Visit.objects.all()),
            'Question': len(models.Question.objects.all()),
        }
        self.test_data = {
            'username': '******',
            'title': 'Test CE1',
            'description_plain_text': 'A culture event happened',
            'differences': 'Last time it was different',
            'interpretation': 'It probably has meaning',
            'nationals_present': 'Initial data',
            'team_present': 'Steve',
            'date': '2019-02-20',
            'phonetic_text': 'foᵘnɛtɪks',
            'orthographic_text': 'orthographic',
            'tags': 'taggie',
            'question': 'Does this test work?',
            'answer': 'Yes, it does!'}

        self.client.login(username='******', password='******')
        ce = models.CultureEvent(title=self.test_data['title'],
                                 description_plain_text=self.test_data['description_plain_text'],
                                 differences=self.test_data['differences'],
                                 interpretation=self.test_data['interpretation'], )
        ce.save()
        ce2 = models.CultureEvent(title='TestCE2')
        ce2.save()
        ce.tags.add(self.test_data['tags'])
        visit = models.Visit(nationals_present=self.test_data['nationals_present'],
                             team_present=self.test_data['team_present'],
                             date=self.test_data['date'],
                             ce=ce)
        visit.save()
        text = models.Text(ce=ce,
                           phonetic_text=self.test_data['phonetic_text'],
                           orthographic_text=self.test_data['orthographic_text'])
        text.save()
        text2 = models.Text(ce=ce,
                            phonetic_text='phonetic_text2',
                            orthographic_text=self.test_data['orthographic_text'])
        text2.save()
        q = models.Question(ce=ce,
                            question=self.test_data['question'],
                            answer=self.test_data['answer'])
        q.save()

        self.test_ce1_pk = str(self.prexisiting_model_objects['CE'] + 1)
        self.test_ce2_pk = str(self.prexisiting_model_objects['CE'] + 2)
        self.test_text1_pk = str(self.prexisiting_model_objects['Text'] + 1)
        self.test_text2_pk = str(self.prexisiting_model_objects['Text'] + 2)
        self.test_visit_pk = str(self.prexisiting_model_objects['Visit'] + 1)
        self.test_question_pk = str(self.prexisiting_model_objects['Question'] + 1)
        self.new_ce_pk = str(self.prexisiting_model_objects['CE'] + 3)
        self.test_ce1_upload_path = os.path.join(base_settings.MEDIA_ROOT, 'CultureEventFiles', str(self.test_ce1_pk))
        self.test_files_path = os.path.join(base_settings.BASE_DIR, 'CLAHub', 'assets', 'test_data')
        self.test_pic1_path = os.path.join(self.test_files_path, 'test_pic1.jpg')
        self.test_audio1_path = os.path.join(self.test_files_path, 'test_audio1.mp3')
        self.test_audio2_path = os.path.join(self.test_files_path, 'test_audio2.mp3')
        self.upload_folder = os.path.join(base_settings.MEDIA_ROOT, 'CultureEventFiles')

        # formset IDs are and CEs are picked up through the view normally, but need to be supplied for tests
        # text-0-ce refers is the CE.pk used as foreign key
        # text-0-id refers to the text.pk
        self.standard_post = {'text-TOTAL_FORMS': 2,
                              'text-INITIAL_FORMS': 2,
                              'question-TOTAL_FORMS': 1,
                              'question-INITIAL_FORMS': 1,
                              'visit-TOTAL_FORMS': 1,
                              'visit-INITIAL_FORMS': 1,
                              'title': self.test_data['title'],
                              'description_plain_text': self.test_data['description_plain_text'],
                              'tags': self.test_data['tags'],
                              'differences': self.test_data['differences'],
                              'interpretation': self.test_data['interpretation'],
                              'text-0-phonetic_text': self.test_data['phonetic_text'],
                              'text-0-orthographic_text': self.test_data['orthographic_text'],
                              'text-0-ce': self.test_ce1_pk,
                              'text-0-id': 1,
                              'text-1-phonetic_text': self.test_data['phonetic_text'],
                              'text-1-orthographic_text': self.test_data['orthographic_text'],
                              'text-1-ce': self.test_ce1_pk,
                              'text-1-id': '2',
                              'visit-0-ce': self.test_ce1_pk,
                              'visit-0-id': 1,
                              'visit-0-team_present': self.test_data['team_present'],
                              'visit-0-nationals_present': 'Posted_data',
                              'visit-0-date': self.test_data['date'],
                              'question-0-ce': self.test_ce1_pk,
                              'question-0-id': 3,
                              'question-0-question': self.test_data['question'],
                              'question-0-answer': self.test_data['answer']
                              }

        self.new_post = {'title': 'Test CE',
                         'description_plain_text': self.test_data['description_plain_text'],
                         'visit-0-date': self.test_data['date'],
                         'visit-0-nationals_present': self.test_data['nationals_present'],
                         'visit-0-team_present': self.test_data['team_present'],
                         'text-TOTAL_FORMS': 0,
                         'text-INITIAL_FORMS': 0,
                         'question-TOTAL_FORMS': 0,
                         'question-INITIAL_FORMS': 0,
                         'visit-TOTAL_FORMS': 1,
                         'visit-INITIAL_FORMS': 0
                         }