Exemplo n.º 1
0
 def test_async_exporter(self):
     exp = AsyncNdbExporter(2)
     for i in range(self.expected):
         instance = UnitTestModel()
         instance.foo = str(i)
         exp.append(instance)
     exp.flush()
     result = UnitTestModel.query().fetch()
     self.assertEqual(len(result), self.expected)
Exemplo n.º 2
0
 def test_multi_exporter(self):
     exp = AsyncNdbExporter(2)
     for i in range(self.expected):
         instance = UnitTestModel()
         exp.append(instance)
         instance = AnotherUnitTestModel()
         exp.append(instance)
     exp.flush()
     result1 = UnitTestModel.query().fetch()
     result2 = AnotherUnitTestModel.query().fetch()
     actual_count = len(result1) + len(result2)
     expected_count = self.expected * 2
     self.assertEqual(actual_count, expected_count)
Exemplo n.º 3
0
    def test_sharded_student_importer(self):
        dummy_count = self.config.estimated_student_count
        self.write_stub_student_file(dummy_count)
        exp = AsyncNdbExporter(dummy_count)

        # Prep work: load student stubs to database with sharding enabled
        imp = StubCsvImporter(self.config, use_shards=True)
        for stu in imp.generate_single():
            exp.append(stu)
        exp.flush()
        self.assertEqual(dummy_count, len(Student.get_all_id_numbers()))

        imp = ShardedStudentImporter()
        self.check_importer_count(dummy_count, imp, multi=True)
        imp = ShardedStudentImporter()
        self.check_importer_count(dummy_count, imp, multi=False)