Ejemplo n.º 1
0
 def test_project_branches(self):
     """Test getting project branches"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'commit': {
             'branch': 'master',
         }
     }, {
         'project': project.name,
         'commit': {
             'branch': 'develop',
         }
     }, {
         'project': project.name,
         'commit': {
             'branch': 'master',
         }
     }, {
         'project': project.name,
         'commit': {
             'branch': 'develop',
         }
     }])
     set(project.branches).should.be.equal({'master', 'develop'})
Ejemplo n.º 2
0
 def test_fail(self):
     """Test redirect to fail badge"""
     project = factories.ProjectFactory.create()
     Tasks.insert({
         'created': datetime(2010, 10, 10),
         'status': const.STATUS_FAILED,
         'project': project.name,
     })
     self._get_and_assert(project.name, 'fail')
Ejemplo n.º 3
0
 def test_success(self):
     """Test redirect to success badge"""
     project = factories.ProjectFactory.create()
     Tasks.insert({
         'created': datetime(2010, 10, 10),
         'status': const.STATUS_SUCCESS,
         'project': project.name,
     })
     self._get_and_assert(project.name, 'success')
Ejemplo n.º 4
0
 def test_fail(self):
     """Test redirect to fail badge"""
     project = factories.ProjectFactory.create()
     Tasks.insert({
         'created': datetime(2010, 10, 10),
         'status': const.STATUS_FAILED,
         'project': project.name,
     })
     self._get_and_assert(project.name, 'fail')
Ejemplo n.º 5
0
 def test_success(self):
     """Test redirect to success badge"""
     project = factories.ProjectFactory.create()
     Tasks.insert({
         'created': datetime(2010, 10, 10),
         'status': const.STATUS_SUCCESS,
         'project': project.name,
     })
     self._get_and_assert(project.name, 'success')
Ejemplo n.º 6
0
 def test_get_negative_trend(self):
     """Test get negative trend"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'commit': {'branch': 'branch'},
         'success_percent': n,
         'created': num,
     } for num, n in enumerate(range(5, 1, -1))])
     project.get_trend().should.be.lower_than(0)
Ejemplo n.º 7
0
 def test_update_day_time_statistic(self):
     """Test update day time statistic"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'success_percent': 10,
         'status': STATUS_SUCCESS,
         'created': datetime.now() + timedelta(hours=4 * part),
     } for part in range(6)])
     project.update_day_time_statistic()
     len(project.day_time_statistic).should.be.ok
Ejemplo n.º 8
0
 def test_update_week_statistic(self):
     """Test update week statistic"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'success_percent': 10,
         'status': STATUS_SUCCESS,
         'created': datetime.now() + timedelta(days=day),
     } for day in range(7)])
     project.update_week_statistic()
     len(project.week_statistic).should.be.ok
Ejemplo n.º 9
0
 def test_update_day_time_statistic(self):
     """Test update day time statistic"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'success_percent': 10,
         'status': STATUS_SUCCESS,
         'created': datetime.now() + timedelta(hours=4 * part),
     } for part in range(6)])
     project.update_day_time_statistic()
     len(project.day_time_statistic).should.be.ok
Ejemplo n.º 10
0
 def test_update_week_statistic(self):
     """Test update week statistic"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'success_percent': 10,
         'status': STATUS_SUCCESS,
         'created': datetime.now() + timedelta(days=day),
     } for day in range(7)])
     project.update_week_statistic()
     len(project.week_statistic).should.be.ok
Ejemplo n.º 11
0
 def test_get_negative_trend(self):
     """Test get negative trend"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'commit': {
             'branch': 'branch'
         },
         'success_percent': n,
         'created': num,
     } for num, n in enumerate(range(5, 1, -1))])
     project.get_trend().should.be.lower_than(0)
Ejemplo n.º 12
0
 def test_project_branches(self):
     """Test getting project branches"""
     project = factories.ProjectFactory()
     Tasks.insert([{'project': project.name, 'commit': {
         'branch': 'master',
     }}, {'project': project.name, 'commit': {
         'branch': 'develop',
     }}, {'project': project.name, 'commit': {
         'branch': 'master',
     }}, {'project': project.name, 'commit': {
         'branch': 'develop',
     }}])
     set(project.branches).should.be.equal({'master', 'develop'})
Ejemplo n.º 13
0
 def test_unknown_because_last_task_not_finished(self):
     """Test unknown because not tasks performed"""
     project = factories.ProjectFactory.create()
     Tasks.insert([{
         'created': datetime(2010, 10, 10),
         'status': const.STATUS_SUCCESS,
         'project': project.name,
     }, {
         'created': datetime(2011, 11, 11),
         'status': const.STATUS_NEW,
         'project': project.name,
     }])
     self._get_and_assert(project.name, 'unknown')
Ejemplo n.º 14
0
 def test_unknown_because_last_task_not_finished(self):
     """Test unknown because not tasks performed"""
     project = factories.ProjectFactory.create()
     Tasks.insert([{
         'created': datetime(2010, 10, 10),
         'status': const.STATUS_SUCCESS,
         'project': project.name,
     }, {
         'created': datetime(2011, 11, 11),
         'status': const.STATUS_NEW,
         'project': project.name,
     }])
     self._get_and_assert(project.name, 'unknown')
 def test_attach_success_percent_only_with_dashboard_branch(self):
     """Test attach success percent only with dashboard branch"""
     project = factories.ProjectFactory(
         owner=self.user, dashboard_branch='branch',
     )
     Tasks.insert([{
         'project': project.name,
         'commit': {'branch': 'branch'},
         'created': datetime(2005, 5, 5),
         'success_percent': 12,
     }, {
         'project': project.name,
         'commit': {'branch': 'test'},
         'created': datetime(2006, 5, 5),
         'success_percent': 92,
     }])
     response = self.api_client.get(
         '{}{}/?with_success_percent=true'.format(self.url, project.name),
     )
     self.deserialize(response)['success_percents'].should.be.equal([12])
Ejemplo n.º 16
0
 def test_attach_success_percent_only_with_dashboard_branch(self):
     """Test attach success percent only with dashboard branch"""
     project = factories.ProjectFactory(
         owner=self.user,
         dashboard_branch='branch',
     )
     Tasks.insert([{
         'project': project.name,
         'commit': {
             'branch': 'branch'
         },
         'created': datetime(2005, 5, 5),
         'success_percent': 12,
     }, {
         'project': project.name,
         'commit': {
             'branch': 'test'
         },
         'created': datetime(2006, 5, 5),
         'success_percent': 92,
     }])
     response = self.api_client.get(
         '{}{}/?with_success_percent=true'.format(self.url, project.name), )
     self.deserialize(response)['success_percents'].should.be.equal([12])