def test_repository_find_all_count(self): self.repository.save(rangevoting.RangeVote(uuid.uuid4(), '?', ['c1', 'c2'])) self.repository.save(rangevoting.RangeVote(uuid.uuid4(), '?', ['c1', 'c2'])) elements = self.repository.find(1) self.assertEqual(1, len(elements))
def test_repository_find_all_order(self): self.repository.save(rangevoting.RangeVote(uuid.uuid4(), 'Q1?', ['c1', 'c2'])) self.repository.save(rangevoting.RangeVote(uuid.uuid4(), 'Q2?', ['c1', 'c2'])) elements = self.repository.find(1) self.assertEqual('Q2?', elements[0].question)
def test_repository_find_all(self): self.repository.save(rangevoting.RangeVote(uuid.uuid4(), '?', ['c1', 'c2'])) self.repository.save(rangevoting.RangeVote(uuid.uuid4(), '?', ['c1', 'c2'])) elements = self.repository.find() self.assertEqual(2, len(elements)) self.assertTrue(isinstance(elements[0], rangevoting.RangeVote))
def test_rangevote_has_question_and_choices_attributes(self): question = 'Q?' choices = ['a', 'b'] rangevote = rangevoting.RangeVote(1, question, choices) self.assertEqual(question, rangevote.question) self.assertEqual(choices, rangevote.choices)
def test_repository_save(self): rangevote = rangevoting.RangeVote(uuid.uuid4(), '?', ['c1', 'c2']) self.repository.save(rangevote) element = self.database.rangevote.find_one() self.assertEqual(rangevote.question, element['question']) self.assertEqual(rangevote.choices, element['choices'])
def test_get_rangevote(self): server.app.query_dispatcher = SpyQueryDispatcher( rangevoting.RangeVote(uuid=1, question='q?', choices=['c1', 'c2']).serialize()) response = self.app.get( '/rangevotes/375ce742-495f-4b0c-b831-3fb0dcc61b17', content_type='application/json') self.assertEqual(200, response.status_code) self.assertEqual('375ce742-495f-4b0c-b831-3fb0dcc61b17', server.app.query_dispatcher.last_query.uuid)
def test_has_empty_votes_attributes(self): rangevote = rangevoting.RangeVote(1, 'Q?', ['a', 'b']) self.assertEqual([], rangevote.votes)
def test_rangevote_has_unique_identifier_created_during_its_creation(self): rangevote = rangevoting.RangeVote(1, 'Q?', ['a', 'b']) self.assertIsNotNone(rangevote.uuid)