Beispiel #1
0
    def test_command_call(self):
        commands_dict = get_commands()
        self.assertTrue(self.COMMAND in commands_dict)

        saved_streams = sys.stdout, sys.stderr

        sys.stdout = self.Output()
        sys.stderr = self.Output()

        prefix = "stderr:"
        has_errors = False

        try:
            call_command(self.COMMAND, tee=1, prefix=prefix)

        except:
            has_errors = True

        self.assertEqual(has_errors, False)

        valid_stdout = ""
        valid_stderr = ""

        for k, v in count_instances().items():
            row = "%s\t%d" % (k, v)
            valid_stdout += "%s\n" % row
            valid_stderr += "%s %s\n" % (prefix, row)

        self.assertEquals(sys.stdout.text, valid_stdout)
        self.assertEquals(sys.stderr.text, valid_stderr)

        sys.stdout, sys.stderr = saved_streams
Beispiel #2
0
    def test_instance_num(self):
        """
        Calculate number of instances using models.get_models() and compare
        """
        result = {}
        for m in models.get_models():
            model_name = "%s.%s" % (m.__module__, m.__name__)
            result[model_name] = m._default_manager.count()

        self.assertEquals(result, count_instances())