コード例 #1
0
 def test_invalidNicknameTooLong(self):
     """Test a line with a router nickname which is way too long."""
     self.makeRLine(nick='ThisIsAReallyReallyLongRouterNickname')
     fields = networkstatus.parseRLine(self.line)
     nick, ident, desc = fields[:3]
     this(nick).should.be(None)
     the(ident).should.be.a(basestring)
     the(desc).should.be(None)
コード例 #2
0
 def test_invalidNicknameNonAlphanumeric(self):
     """Test a line with a non-alphanumeric router nickname."""
     self.makeRLine(nick='abcdef/*comment*/')
     fields = networkstatus.parseRLine(self.line)
     nick, ident, desc = fields[:3]
     this(nick).should.be(None)
     the(ident).should.be.a(basestring)
     the(desc).should.be(None)
コード例 #3
0
 def test_valid(self):
     """Test a valid 'r'-line."""
     self.makeRLine()
     fields = networkstatus.parseRLine(self.line)
     nick, ident, desc, ts, ip, port = fields[:6]
     the(nick).should.be.equal(self.nick)
     the(ident).should.be.equal(self.rawIdent)
     the(desc).should.be.equal(self.rawDesc)
     the(ts).should.be.ok
     the(ip).should.be.ok
コード例 #4
0
    def test_invalidDescriptorDigest_invalidBase64(self):
        """Test line with '%$>@,<' for an identity digest."""
        self.makeRLine(desc='%$>#@,<')
        fields =  networkstatus.parseRLine(self.line)
        nick, ident, desc, ts, ip = fields[:5]

        the(nick).should.be.ok
        the(nick).should.be.a(basestring)
        the(nick).should.equal(self.nick)
        the(ident).should.be(None)
        the(desc).should.be(None)
コード例 #5
0
    def test_invalidIdent_withBase64padding(self):
        """Test a line with invalid base64 (no padding) identity digest."""
        self.makeRLine(ident=self.ident + '==')
        fields = networkstatus.parseRLine(self.line)
        nick, ident, desc = fields[:3]

        the(nick).should.be.ok
        the(nick).should.be.a(basestring)
        the(nick).should.be.equal(self.nick)
        the(ident).should.be.equal(None)
        the(desc).should.be.equal(None)
コード例 #6
0
    def test_invalidIdentBase64(self):
        """Test line with '%$>@,<' for an identity digest."""
        self.makeRLine(ident='%$>#@,<')
        (nick, ident, desc, ts,
         ip, port, dirp) = networkstatus.parseRLine(self.line)

        the(nick).should.be.ok
        the(nick).should.be.a(basestring)
        the(nick).should.equal(self.nick)
        the(ident).should.be(None)
        the(desc).should.be(None)
コード例 #7
0
    def test_invalidDescriptorDigest_singleQuoteChar(self):
        """Test with a single quote character for the descriptor digest."""
        self.makeRLine(desc=chr(0x27))
        fields = networkstatus.parseRLine(self.line)
        nick, ident, desc = fields[:3]

        the(nick).should.be.ok
        the(nick).should.be.a(basestring)
        the(nick).should.be.equal(self.nick)
        the(ident).should.be.equal(self.rawIdent)
        the(desc).should.be.equal(None)
コード例 #8
0
    def test_invalidIPAddress(self):
        """Test a line with an invalid IP address."""
        self.makeRLine(ip='0.0.0.0')
        fields = networkstatus.parseRLine(self.line)
        nick, ident, desc, ts, ip, port = fields[:6]

        the(nick).should.be.equal(self.nick)
        the(ident).should.be.equal(self.rawIdent)

        # descDigest is set to `None` if there is an error while parsing:
        the(desc).should.be(None)
        the(ts).should.be(None)
        the(ip).should.be(None)
コード例 #9
0
    def test_invalidTimestamp(self):
        """Test line with two large integers for the timestamp."""
        self.makeRLine(ts='123456789 987654321')
        fields = networkstatus.parseRLine(self.line)
        nick, ident, desc, ts, ip, port = fields[:6]

        the(nick).should.be.equal(self.nick)
        the(ident).should.be.equal(self.rawIdent)

        # descDigest is set to `None` if there is an error while parsing:
        the(desc).should.be(None)
        the(ts).should.be(None)
        the(ip).should.be(None)
コード例 #10
0
    def test_wrongFieldOrder(self):
        """Test a line with the identity and descriptor digests switched."""
        self.makeRLine(desc=self.ident, ident=self.desc)
        fields = networkstatus.parseRLine(self.line)
        nick, others = fields[0], fields[1:]

        this(nick).should.be.ok
        this(nick).should.be.a(basestring)
        this(nick).should.equal(self.nick)

        the(others).should.be.a(tuple)
        the(others).should.have.length_of(6)
        for other in others:
            the(other).should.be(None)
コード例 #11
0
    def test_useChangedSettings(self):
        # This deepcopying must be done to avoid changing the State object
        # which is used for the rest of the tests.

        thatConfig = deepcopy(self.config)
        thatState = deepcopy(self.state)

        setattr(thatConfig, 'FOO', 'fuuuuu')
        setattr(thatConfig, 'BAR', 'all of the things')
        setattr(thatConfig, 'LOGFILE', 42)

        this(thatConfig).should.have.property('FOO').being.a(basestring)
        this(thatConfig).should.have.property('BAR').being.a(basestring)
        this(thatConfig).should.have.property('LOGFILE').being.an(int)
        this(thatConfig).should.have.property('BRIDGE_FILES').being.a(list)

        the(thatConfig.FOO).must.equal('fuuuuu')
        the(thatConfig.BAR).must.equal('all of the things')
        the(thatConfig.LOGFILE).must.equal(42)

        the(thatState).should.have.property('useChangedSettings')
        the(thatState.useChangedSettings).should.be(callable)
        thatState.useChangedSettings(thatConfig)

        the(thatState.FOO).should.equal('fuuuuu')
        the(thatState).should.have.property('FOO').being.a(basestring)
        the(thatState).should.have.property('BAR').being.a(basestring)
        the(thatState).should.have.property('LOGFILE').being.an(int)
        the(thatState.FOO).must.equal(thatConfig.FOO)
        the(thatState.BAR).must.equal(thatConfig.BAR)
        the(thatState.LOGFILE).must.equal(thatConfig.LOGFILE)

        this(thatState.config).should.have.property('FOO')
        this(thatState.config).should.have.property('BAR')
        this(thatState.config).should.have.property('LOGFILE').being.an(int)
        this(thatState.config).should.have.property('BRIDGE_FILES').being.a(
            list)
コード例 #12
0
 def test_persistent_state(self):
     the(persistent._state).should.be.a(persistent.State)
コード例 #13
0
ファイル: test_persistent.py プロジェクト: gsathya/bridgedb
 def test_STATEFILE(self):
     this(self.state).should.have.property('statefile')
     the(self.state.statefile).should.be.a(str)
コード例 #14
0
ファイル: test_persistent.py プロジェクト: gsathya/bridgedb
 def test_docstring_persistentState(self):
     the(self.state).should.have.property('__doc__').being.a(str)
コード例 #15
0
ファイル: test_persistent.py プロジェクト: gsathya/bridgedb
    def test_useChangedSettings(self):
        # This deepcopying must be done to avoid changing the State object
        # which is used for the rest of the tests.

        thatConfig = deepcopy(self.config)
        thatState  = deepcopy(self.state)

        setattr(thatConfig, 'FOO', 'fuuuuu')
        setattr(thatConfig, 'BAR', 'all of the things')
        setattr(thatConfig, 'LOGFILE', 42)

        this(thatConfig).should.have.property('FOO').being.a(basestring)
        this(thatConfig).should.have.property('BAR').being.a(basestring)
        this(thatConfig).should.have.property('LOGFILE').being.an(int)
        this(thatConfig).should.have.property('BRIDGE_FILES').being.a(list)

        the(thatConfig.FOO).must.equal('fuuuuu')
        the(thatConfig.BAR).must.equal('all of the things')
        the(thatConfig.LOGFILE).must.equal(42)

        the(thatState).should.have.property('useChangedSettings')
        the(thatState.useChangedSettings).should.be(callable)
        thatState.useChangedSettings(thatConfig)

        the(thatState.FOO).should.equal('fuuuuu')
        the(thatState).should.have.property('FOO').being.a(basestring)
        the(thatState).should.have.property('BAR').being.a(basestring)
        the(thatState).should.have.property('LOGFILE').being.an(int)
        the(thatState.FOO).must.equal(thatConfig.FOO)
        the(thatState.BAR).must.equal(thatConfig.BAR)
        the(thatState.LOGFILE).must.equal(thatConfig.LOGFILE)

        this(thatState.config).should.have.property('FOO')
        this(thatState.config).should.have.property('BAR')
        this(thatState.config).should.have.property('LOGFILE').being.an(int)
        this(thatState.config).should.have.property(
            'BRIDGE_FILES').being.a(list)
コード例 #16
0
ファイル: test_persistent.py プロジェクト: gsathya/bridgedb
 def test_persistent_state(self):
     the(persistent._state).should.be.a(persistent.State)
コード例 #17
0
ファイル: test_celeries.py プロジェクト: DrManchas/lettuce
def test_failfast():
    'passing --failfast to the harvest command will cause lettuce to stop in the first failure'

    status, output = run_scenario(**{'--failfast': None})

    the(output).should.contain("This one is present")
    the(output).should.contain("Celeries before all")
    the(output).should.contain("Celeries before harvest")
    the(output).should.contain("Celeries before feature 'Test the django app leaves'")
    the(output).should.contain("Celeries before scenario 'This one is present'")

    the(output).should.contain("Celeries before step 'Given I say foo bar'")
    the(output).should.contain("Celeries after step 'Given I say foo bar'")
    the(output).should.contain("Celeries before step 'Then it fails'")
    the(output).should.contain("Celeries after step 'Then it fails'")

    the(output).should.contain("Celeries after scenario 'This one is present'")
    the(output).should.contain("Celeries after feature 'Test the django app leaves'")
    the(output).should.contain("Celeries after harvest")
    the(output).should.contain("Celeries after all")

    the(output).should_not.contain("This one is never called")
コード例 #18
0
def test_failfast():
    'passing --failfast to the harvest command will cause lettuce to stop in the first failure'

    FileSystem.pushd(current_directory, "django", "celeries")

    status, output = commands.getstatusoutput(
        "python manage.py harvest --verbosity=3 --failfast")

    the(output).should.contain("This one is present")
    the(output).should.contain("Celeries before all")
    the(output).should.contain("Celeries before harvest")
    the(output).should.contain(
        "Celeries before feature 'Test the django app leaves'")
    the(output).should.contain(
        "Celeries before scenario 'This one is present'")

    the(output).should.contain("Celeries before step 'Given I say foo bar'")
    the(output).should.contain("Celeries after step 'Given I say foo bar'")
    the(output).should.contain("Celeries before step 'Then it fails'")
    the(output).should.contain("Celeries after step 'Then it fails'")

    the(output).should.contain("Celeries after scenario 'This one is present'")
    the(output).should.contain(
        "Celeries after feature 'Test the django app leaves'")
    the(output).should.contain("Celeries after harvest")
    the(output).should.contain("Celeries after all")

    the(output).should_not.contain("This one is never called")

    FileSystem.popd()
コード例 #19
0
ファイル: test_celeries.py プロジェクト: Bunch/lettuce
def test_failfast():
    'passing --failfast to the harvest command will cause lettuce to stop in the first failure'

    FileSystem.pushd(current_directory, "django", "celeries")

    status, output = commands.getstatusoutput("python manage.py harvest --verbosity=3 --failfast")

    the(output).should.contain("This one is present")
    the(output).should.contain("Celeries before all")
    the(output).should.contain("Celeries before harvest")
    the(output).should.contain("Celeries before feature 'Test the django app leaves'")
    the(output).should.contain("Celeries before scenario 'This one is present'")

    the(output).should.contain("Celeries before step 'Given I say foo bar'")
    the(output).should.contain("Celeries after step 'Given I say foo bar'")
    the(output).should.contain("Celeries before step 'Then it fails'")
    the(output).should.contain("Celeries after step 'Then it fails'")

    the(output).should.contain("Celeries after scenario 'This one is present'")
    the(output).should.contain("Celeries after feature 'Test the django app leaves'")
    the(output).should.contain("Celeries after harvest")
    the(output).should.contain("Celeries after all")

    the(output).should_not.contain("This one is never called")

    FileSystem.popd()
コード例 #20
0
 def test_docstring_persistentState(self):
     the(self.state).should.have.property('__doc__').being.a(str)
コード例 #21
0
    def test_invalidDescriptorDigest_withBase64padding(self):
        """Test a line with invalid base64 (no padding) descriptor digest."""
        self.makeRLine(desc=self.desc + '==')
        fields = networkstatus.parseRLine(self.line)
        nick, ident, desc, ts, ip = fields[:5]

        the(nick).should.be.ok
        the(nick).should.be.a(basestring)
        the(nick).should.be.equal(self.nick)

        the(ident).should.be.a(basestring)
        the(ident).should.be.equal(self.rawIdent)

        the(desc).should.be.equal(None)
        the(ts).should.be.equal(None)
        the(ip).should.be.equal(None)
コード例 #22
0
 def test_STATEFILE(self):
     this(self.state).should.have.property('statefile')
     the(self.state.statefile).should.be.a(str)
コード例 #23
0
ファイル: test_celeries.py プロジェクト: Acetonen/lettuce-py3
def test_failfast():
    'passing --failfast to the harvest command will cause lettuce to stop in the first failure'

    status, output = run_scenario(**{'--failfast': None})

    the(output).should.contain("This one is present")
    the(output).should.contain("Celeries before all")
    the(output).should.contain("Celeries before harvest")
    the(output).should.contain(
        "Celeries before feature 'Test the django app leaves'")
    the(output).should.contain(
        "Celeries before scenario 'This one is present'")

    the(output).should.contain("Celeries before step 'Given I say foo bar'")
    the(output).should.contain("Celeries after step 'Given I say foo bar'")
    the(output).should.contain("Celeries before step 'Then it fails'")
    the(output).should.contain("Celeries after step 'Then it fails'")

    the(output).should.contain("Celeries after scenario 'This one is present'")
    the(output).should.contain(
        "Celeries after feature 'Test the django app leaves'")
    the(output).should.contain("Celeries after harvest")
    the(output).should.contain("Celeries after all")

    the(output).should_not.contain("This one is never called")