Example #1
0
    def test_get_tests_filters_names(self):
        test_result = TestResult()

        test_result.tests['bacon', 1] = Test(name='bacon', series=1)
        test_result.tests['bacon', 2] = Test(name='bacon', series=2)
        test_result.tests['spam', 2] = Test(name='spam', series=2)

        self.assertEquals(len(test_result._get_tests(name='bacon')), 2)
Example #2
0
    def test_average_test_duration(self):
        t = Test(TIME1)
        t.end = TIME2

        test_result = TestResult()
        test_result.tests['toto', 1] = t
        test_result.tests['tutu', 1] = t

        self.assertEquals(test_result.average_test_duration(), 120)
Example #3
0
    def test_average_test_duration(self):
        t = Test(TIME1)
        t.end = TIME2

        test_result = TestResult()
        test_result.tests['toto', 1] = t
        test_result.tests['tutu', 1] = t

        self.assertEquals(test_result.average_test_duration(), 120)
Example #4
0
 def startTest(self, test, loads_status=None, agent_id=None):
     hit, user = loads_status[:2]
     key = self._get_key(test, loads_status, agent_id)
     current = self._get_key(None, loads_status, agent_id)
     t = Test(name=test, hit=hit, user=user)
     # also record the *current* test for the given loads_status
     self.current_tests[current] = self.tests[key] = t
Example #5
0
    def test_file_is_written(self):

        # Create a fake test result object
        test_result = FakeTestResult()

        # populate it with some fake hits...
        hit = Hit(url='http://notmyidea.org',
                  method='GET',
                  status=200,
                  started=TIME1,
                  elapsed=_1,
                  loads_status=(1, 2, 3, 4))
        test_result.hits.append(hit)

        # ...and some fake tests.
        test_result.tests['bacon', 1] = Test(TIME1, name='bacon',
                                             series=1, hit=1, user=1)
        test_result.tests['bacon', 1].success = 1

        test_result.tests['egg', 1] = Test(TIME1, name='egg',
                                           series=1, hit=1, user=1)
        test_result.tests['egg', 1].errors = [(None, None, 'youpi yeah'), ]

        tmpdir = tempfile.mkdtemp()
        try:
            output = FunkloadOutput(
                test_result,
                {'output_funkload_filename': '%s/funkload.xml' % tmpdir,
                 'fqn': 'MyTest',
                 'hits': 200})
            output.flush()

            with open('%s/funkload.xml' % tmpdir) as f:
                content = f.read()
                test = (('<response cycle="000" cvus="2" thread="000" '
                         'suite="" name="" step="001" number="001" type="GET" '
                         'result="Successful" url="http://notmyidea.org" '
                         'code="200" description="" time="'),
                        ('" duration="1.0" />'))
                for t in test:
                    self.assertIn(t, content)

                test = (('<testResult cycle="000" cvus="1" thread="000" '
                         'suite="" name="" time="'),
                        ('" result="Success" steps="1" duration="0" '
                         'connection_duration="" requests="" pages="" '
                         'xmlrpc="" redirects="" images="" links="" />'))
                for t in test:
                    self.assertIn(t, content)

                test = (('<testResult cycle="000" cvus="1" thread="000" '
                         'suite="" name="" time="'),
                        ('result="Failure" steps="1" duration="0" '
                         'connection_duration="" requests="" pages="" '
                         'xmlrpc="" redirects="" images="" links="" '
                         'traceback="youpi yeah" />'))
                for t in test:
                    self.assertIn(t, content)

        finally:
            shutil.rmtree(tmpdir)
Example #6
0
 def test_success_rate_when_failures_and_success(self):
     test = Test()
     test.success = 2
     test.failures.append(0)  # Acts as a failure.
     test.failures.append(0)
     self.assertEquals(test.success_rate, 0.5)
Example #7
0
 def test_duration_is_valid(self):
     test = Test(TIME1)
     test.end = TIME2
     self.assertEquals(test.duration, 120)
Example #8
0
 def test_success_rate_when_failures_and_success(self):
     test = Test()
     test.success = 2
     test.failures.append(0)  # Acts as a failure.
     test.failures.append(0)
     self.assertEquals(test.success_rate, 0.5)
Example #9
0
 def test_success_rate_when_none(self):
     test = Test()
     self.assertEquals(test.success_rate, 1)
Example #10
0
 def test_duration_is_valid(self):
     test = Test(TIME1)
     test.end = TIME2
     self.assertEquals(test.duration, 120)
Example #11
0
 def test_duration_is_zero_if_not_finished(self):
     test = Test()
     # no end value is provided
     self.assertEquals(test.duration, 0)