Пример #1
0
    def test_update_existing_build(self):
         """ Tests that updating a build with build results works correctly
             checks for:
                 correct retrieval of guild
                 correct update """
         pass
         test_build = Build.new_from_json(self.json)
	 test_build.save()
         test_build_id = test_build['_id']

         error_msg = "this is an error message"

         test_build.update_with_results(1)
         check = Build.load_from_database(test_build_id)
         self.assertEqual(check['status'],1)

	 test_build.update_with_results(2, errmsg=error_msg)
	 check = Build.load_from_database(test_build_id)
	 self.assertEqual(check['status'],2)
         self.assertEqual(check['error'],error_msg)
Пример #2
0
    def test_failed_build_retrieval(self):
        """ Tests that bad retrieves fail reasonably
            checks for:
                reasonable error given invalid ID
                reasonable errors for database errors """

    	with self.assertRaises(BuildErrorException):
    	    test_build  = Build()
    	    test_build.load_from_database(id=ObjectId())
    	    # should raise an error because it does
    	    # not exist (database is empty)

        # put in a test object
    	insert_build = Build.new_from_json(self.json)
    	inserted_id = insert_build.save()

    	# check for incorrect ID type
    	with self.assertRaises(BuildErrorException):
    	    test_build = Build()
    	    test_build.load_from_database(id=3)
Пример #3
0
    def test_multiple_build_retrieval(self):
         """ Tests that retrieving multiple builds works correctly """
         # should not be smart enough to tell that matching json is the same build,
         # so we can populate the database with multiple copies of the same build :P
         pass
         save1 = Build.new_from_json(self.json)
	 save1.save()
         save2 = Build.new_from_json(self.json)
	 save2.save()
         Build.new_from_json(self.json).save()
         Build.new_from_json(self.json).save()
         Build.new_from_json(self.json).save()
         Build.new_from_json(self.json).save()

         test_build1_id = save1['_id']
	 test_build2_id = save2['_id']

         # test that we get the right ones
         get_build1 = Build.load_from_database(test_build1_id)
         get_build2 = Build.load_from_database(test_build2_id)
         self.assertNotEqual(get_build1['_id'], get_build2['_id'])
         self.assertEqual(get_build1['_id'], test_build1_id)
         self.assertEqual(get_build2['_id'], test_build2_id)
Пример #4
0
    def test_build_retrieval(self):
         """ Tests that Build objects are correctly retrieved from the
             database given an ID (as would be used by the BuildQueue)
             checks for:
                 correct Document retrieved
                 valid JSON returned """

         test_build = Build.new_from_json(self.json)
         test_build.save()

         get_build = Build.load_from_database(test_build._id)

         # check that they got the same thing
         self.assertEqual(get_build._id, test_build._id)