示例#1
0
    def setUp(self):
        self.keyword = 'KEYWORD'
        text_no_keyword = 'blah blah blah'
        text_with_keyword = f'blah blah blah {self.keyword} blah blah blah'

        self.signal_with_keyword = SignalFactory()
        NoteFactory(_signal=self.signal_with_keyword, text=text_no_keyword)
        NoteFactory(_signal=self.signal_with_keyword, text=text_no_keyword)
        NoteFactory(_signal=self.signal_with_keyword, text=text_with_keyword)
        NoteFactory(_signal=self.signal_with_keyword, text=text_with_keyword)

        self.signal_no_keyword = SignalFactory()
        NoteFactory(_signal=self.signal_with_keyword, text=text_no_keyword)
示例#2
0
    def test_create_notes_csv(self):
        signal = SignalFactory.create()
        # Add one note to the signal
        notes = NoteFactory(id=1, _signal=signal)

        csv_file = datawarehouse.create_signals_notes_csv(self.csv_tmp_dir)

        self.assertEqual(path.join(self.csv_tmp_dir, 'notes.csv'), csv_file)

        with open(csv_file) as opened_csv_file:
            reader = csv.DictReader(opened_csv_file)
            for row in reader:
                self.assertEqual(row['id'], str(notes.id))
                self.assertEqual(row['_signal_id'], str(notes._signal_id))
                self.assertEqual(row['text'], str(notes.text))
示例#3
0
    def setUp(self):
        self.signal = SignalFactory(id=1,
                                    location__id=1,
                                    status__id=1,
                                    category_assignment__id=1,
                                    reporter__id=1,
                                    priority__id=1)

        self.sia_read_write_user.user_permissions.add(
            Permission.objects.get(codename='sia_can_view_all_categories'))

        # Forcing authentication
        self.client.force_authenticate(user=self.sia_read_write_user)

        # Add one note to the signal
        self.note = NoteFactory(id=1, _signal=self.signal)
示例#4
0
    def test_log_create_note(self):
        self.assertEqual(0, Log.objects.count())

        note = NoteFactory.create(_signal=self.signal)
        SignalLogService.log_create_note(note)

        self.assertSignalsNotInLog(self.signals_no_log)

        self.assertEqual(1, Log.objects.count())
        self.assertEqual(1, self.signal.history_log.count())
        self.assertEqual(
            0,
            self.signal.history_log.exclude(action=Log.ACTION_CREATE).count())
        self.assertEqual(
            1,
            self.signal.history_log.filter(action=Log.ACTION_CREATE).count())
        self.assertEqual(1, note.history_log.count())