Beispiel #1
0
 def test_cheating(self):
     self.texts = [['a', 'b', 'v'], ['а', 'b', 'v']]
     self.results_0 = f"There are no russian symbols in site 1"
     self.results_1 = f"There are russian symbols in site 2"
     self.assertEqual(antiplagiat.compare(self.texts, flag=True)[0],
                      self.results_0)
     self.assertEqual(antiplagiat.compare(self.texts, flag=True)[1],
                      self.results_1)
Beispiel #2
0
 def test_several_texts(self):
     self.texts = [['a', 'b', 'v'], ['a', 'b', 'v'], ['a', 'b', 'v']]
     results = ["hash function: crc32\t shingles length: 2",
                "Similarity between site 1 and site 2: 100.0%",
                "Similarity between site 1 and site 3: 100.0%",
                "Similarity between site 2 and site 3: 100.0%"]
     self.assertEqual(antiplagiat.compare(self.texts), results)
Beispiel #3
0
def execute(cell_id=None):
    """Gets piece of code from cell_id and executes it"""
    try:
        cell_id = int(cell_id)
    except ValueError as e:
        logger.warning(e)
        return redirect('/')

    global current_execute_count
    try:
        current_execute_count += 1
        execute_counters[cell_id] = current_execute_count

        inputs[cell_id] = request.form['input{}'.format(cell_id)]
        texts = parsing(inputs[cell_id].split())
        result = antiplagiat.compare(texts)
    except BaseException as e:
        # anything could happen inside, even `exit()` call
        result = [str(e)]

    outputs[cell_id] = result
    return redirect('/')
Beispiel #4
0
 def test_list(self):
     self.texts = [['a', 'b', 'v'], ['a', 'b', 'v']]
     self.assertIsInstance((antiplagiat.compare(self.texts), list))
Beispiel #5
0
 def test_one_text(self):
     self.text = [['a', 'b', 'v']]
     self.result = ["To compare you should write at least 2 link"]
     self.assertEqual(antiplagiat.compare(self.text), self.result)