示例#1
0
    def test_register_score_nonexisting_war(self):
        phenny = DummyPhenny()
        inputobj = DummyInput(self.nick)
        inputobj.properties.append('score')
        inputobj.properties.append('999 200')
        nanowars.score(phenny, inputobj)

        assert "Volgens de annalen bestaat war %s niet. Ik verlies geen documenten, dus ik vermoed dat je je vergist met het ID :-) " % 999 in phenny.said
示例#2
0
    def test_not_enough_data(self):
        phenny = DummyPhenny()
        inputobj = DummyInput(self.nick)
        inputobj.properties.append('score')
        inputobj.properties.append('942')

        nanowars.score(phenny, inputobj)

        assert 'Ik heb twee getalletjes nodig, %s: het nummer van de war gevolgd door je score' % self.nick in phenny.said, 'Phenny did not say what was wrong, instead she said: %s' % '\n'.join(phenny.said)
示例#3
0
    def test_score_old_war_certain(self):
        start = datetime.datetime.now() - datetime.timedelta(days=1, minutes=10)
        end = datetime.datetime.now() - datetime.timedelta(days=1, minutes=5)
        result = HelperFunctions().call_django('/api/war/new/', 'POST', {'starttime': start.strftime('%s'), 'endtime': end.strftime('%s')})
        self.war = json.loads(result.content)

        phenny = DummyPhenny()
        phenny.expected_score = 200
        phenny.expected_war_id = self.war['id']
        phenny.expected_nick = self.nick

        inputobj = DummyInput(self.nick)
        inputobj.properties.append('score')
        inputobj.properties.append('%s 200 zeker' % self.war['id'])

        nanowars.score(phenny, inputobj)

        expected_say = 'Score %s staat genoteerd voor war %s, %s.' % (phenny.expected_score, phenny.expected_war_id, phenny.expected_nick)
        assert expected_say in phenny.said, 'Expected %s in phenny.said, instead she said: %s' % (expected_say, '\n'.join(phenny.said))
示例#4
0
    def test_score_old_war(self):
        start = datetime.datetime.now() - datetime.timedelta(days=1, minutes=10)
        end = datetime.datetime.now() - datetime.timedelta(days=1, minutes=5)
        result = HelperFunctions().call_django('/api/war/new/', 'POST', {'starttime': start.strftime('%s'), 'endtime': end.strftime('%s')})
        self.war = json.loads(result.content)

        phenny = DummyPhenny()

        inputobj = DummyInput(self.nick)
        inputobj.properties.append('score')
        inputobj.properties.append('%s 200' % self.war['id'])

        nanowars.score(phenny, inputobj)

        expected_said = 'Die war is een dag of meer geleden gestopt. Als je heel zeker bent dat je er nog een score voor wil registreren, zeg dan .score %s %s zeker' % (self.war['id'], 200)
        assert expected_said in phenny.said, 'Expected phenny to say %s, instead she said %s' % (expected_said, '\n'.join(phenny.said))

        result = HelperFunctions().call_django('/api/writer/getscore/', 'POST', {'writer': self.nick, 'war': self.war['id']})
        scoredata = json.loads(result.content)

        assert scoredata == {}, 'Phenny should not have registered score, but got %s from backend.' % scoredata
示例#5
0
    def test_unregister_score(self):
        result = HelperFunctions().call_django('/api/war/new/', 'POST', {'starttime': self.start.strftime('%s'), 'endtime': self.end.strftime('%s')})
        self.war = json.loads(result.content)

        phenny = DummyPhenny()
        phenny.expected_score = 200
        phenny.expected_war_id = self.war['id']
        phenny.expected_nick = self.nick

        inputobj = DummyInput(self.nick)
        inputobj.properties.append('score')
        inputobj.properties.append('%s 200' % self.war['id'])
        nanowars.score(phenny, inputobj)

        result = HelperFunctions().call_django('/api/writer/getscore/', 'POST', {'writer': self.nick, 'war': self.war['id']})
        scoredata = json.loads(result.content)

        expected_response = {'writer': self.nick, 'war': str(self.war['id']), 'score': 200}

        assert scoredata == expected_response, 'Response should be %s, not %s' % (expected_response, scoredata)

        expected_say = 'Score %s staat genoteerd voor war %s, %s.' % (phenny.expected_score, phenny.expected_war_id, phenny.expected_nick)
        assert expected_say in phenny.said

        phenny = DummyPhenny()
        phenny.expected_war_id = self.war['id']
        phenny.expected_nick = self.nick

        inputobj = DummyInput(self.nick)
        inputobj.properties.append('score')
        inputobj.properties.append('%s 0' % self.war['id'])
        nanowars.score(phenny, inputobj)

        expected_said = 'Ik heb je score voor war %s verwijderd, %s.' % (self.war['id'], self.nick)

        assert expected_said in phenny.said, 'Expected phenny to say %s, instead she said %s' % (expected_said, '\n'.join(phenny.said))