~abentley/ci-director/ignore-specified

« back to all changes in this revision

Viewing changes to cidirector/tests/test_update_outcome.py

  • Committer: Aaron Bentley
  • Date: 2016-08-03 15:02:56 UTC
  • mfrom: (178.1.1 started-date)
  • Revision ID: aaron.bentley@canonical.com-20160803150256-nzwtxbhzrzyqrym4
Add 'started' to update-outcome output.

Show diffs side-by-side

added added

removed removed

Lines of Context:
744
744
                    'blocked': [],
745
745
                }},
746
746
            'complete_failure_info': {}, 'release_number': None,
 
747
            'started': '1970-01-01T00:00:00.100000Z',
747
748
            'finished': '1970-01-01T00:00:00.300000Z',
748
749
            'result': {'status': BLESS},
749
750
            'branch': 'gitbranch:master:github.com/juju/juju',
791
792
        self.assertEqual(False, mongo_data['tests']['foo']['vote'])
792
793
 
793
794
    @classmethod
794
 
    def get_job_json(cls, timestamp=100, duration=200):
 
795
    def get_job_json(cls, timestamp=100, duration=200, build_number=1,
 
796
                     branch=None):
795
797
        build_1 = {
796
 
            'number': 1,
 
798
            'number': build_number,
797
799
            'building': False,
798
800
            'timestamp': timestamp,
799
801
            'duration': duration,
 
802
            'artifacts': [],
800
803
            }
 
804
        if branch is not None:
 
805
            build_1['actions'] = {
 
806
                    'parameters': [
 
807
                        {
 
808
                            'name': 'branch',
 
809
                            'value': branch,
 
810
                            },
 
811
                        {
 
812
                            'name': 'revision',
 
813
                            'value': 'asdf',
 
814
                            },
 
815
                        ],
 
816
                    },
 
817
 
801
818
        return {
802
 
                'builds': {'1': build_1},
 
819
                'builds': {str(build_number): build_1},
803
820
                'config': {}
804
821
            }
805
822
 
842
859
        mongo_data = OutcomeState.make_mongo_data(32, rb_data, set(), {})
843
860
        self.assertEqual(['foo'], mongo_data['tests']['bar']['blocked'])
844
861
 
 
862
    def test_test_make_mongo_data_started(self):
 
863
        rb_data = self.get_revision_build_data()
 
864
        lbs_data = set()
 
865
        mongo_data = OutcomeState.make_mongo_data(32, rb_data, lbs_data, {})
 
866
        self.assertEqual('1970-01-01T00:00:00.100000Z', mongo_data['started'])
 
867
 
 
868
        rb_data['foo'] = self.get_job_json(timestamp=500, duration=400)
 
869
        mongo_data = OutcomeState.make_mongo_data(32, rb_data, lbs_data, {})
 
870
        self.assertEqual('1970-01-01T00:00:00.100000Z', mongo_data['started'])
 
871
 
 
872
        rb_data[BUILD_REVISION] = self.get_job_json(
 
873
            timestamp=500, duration=400, build_number=32, branch='foo')
 
874
        mongo_data = OutcomeState.make_mongo_data(32, rb_data, lbs_data, {})
 
875
        self.assertEqual('1970-01-01T00:00:00.500000Z', mongo_data['started'])
 
876
 
845
877
    def test_test_make_mongo_data_finished(self):
846
878
        rb_data = self.get_revision_build_data()
847
879
        lbs_data = set()