## ## Copyright (c) 2006 Jason Dillon ## ## Licensed under the Apache License, Version 2.0 (the "License"); ## you may not use this file except in compliance with the License. ## You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## ## ## $Id: //guest/jason_dillon/p4spam/main/testsuite/test_commands.py#3 $ $Date: 2006/04/12 $ ## import unittest import types from perforce import P4 class PerforceTestCaseSupport(unittest.TestCase): def setUp(this): this.p4 = P4() def assertNotNone(this, value): this.assert_(value != None) ## ## p4.counter() ## ''' Public P4 probably does not like guests to set counters class CounterCommandTestCase(PerforceTestCaseSupport): def testGet(this): counter = this.p4.counter('change') this.assertNotNone(counter) def testSet(this): counter = this.p4.counter('test', 57) # NOTE: set returns a CounterInfo instance, but current value is broke this.assertNotNone(counter) counter = this.p4.counter('test') this.assertNotNone(counter) this.assertEquals(57, counter.value) ''' ## ## p4.counters() ## class CountersCommandTestCase(PerforceTestCaseSupport): def testList(this): counters = this.p4.counters() count = 0 for counter in counters: count = count + 1 this.assertNotEquals(0, count) ## ## p4.describe() ## class DescribeCommandTestCase(PerforceTestCaseSupport): def testList(this): desc = this.p4.describe(1) this.assertNotNone(desc) ## ## p4.diff2() ## class Diff2CommandTestCase(PerforceTestCaseSupport): def test_diff2(this): diff = this.p4.diff2('-u', '//guest/jason_dillon/p4spam/main/bin/p4spam.py#1', '//guest/jason_dillon/p4spam/main/bin/p4spam.py#2') this.assertNotNone(diff) ## ## p4._print() ## class PrintCommandTestCase(PerforceTestCaseSupport): def test_print(this): diff = this.p4._print('//guest/jason_dillon/p4spam/main/bin/p4spam#1') this.assertNotNone(diff) ## ## p4.reviews() ## class ReviewsCommandTestCase(PerforceTestCaseSupport): def test_reviews(this): reviewers = this.p4.reviews('-c', 1) this.assertNotNone(reviewers) count = 0 for reviewer in reviewers: this.assertNotNone(reviewer) count = count + 1 this.assertNotEquals(0, count) ## ## p4.review() ## class ReviewCommandTestCase(PerforceTestCaseSupport): def test_review(this): changeCounter = this.p4.counter('change') reviews = this.p4.review('-c', changeCounter.value - 1) this.assertNotNone(reviews) count = 0 for review in reviews: this.assertNotNone(review) count = count + 1 this.assertNotEquals(0, count) ## ## p4.raw() ## class RawCommandTestCase(PerforceTestCaseSupport): def test_raw(this): lines = this.p4.raw('describe', '-du', 1) this.assertNotNone(lines) this.assertNotEquals(0, len(lines)) ## ## p4.rawstream() ## class RawCommandTestCase(PerforceTestCaseSupport): def test_rawstream(this): stream = this.p4.rawstream('describe', '-du', 1) this.assertNotNone(stream) this.assertEquals(types.FileType, type(stream))